diff options
Diffstat (limited to 'boost/type_traits/has_nothrow_assign.hpp')
-rw-r--r-- | boost/type_traits/has_nothrow_assign.hpp | 75 |
1 files changed, 57 insertions, 18 deletions
diff --git a/boost/type_traits/has_nothrow_assign.hpp b/boost/type_traits/has_nothrow_assign.hpp index 83e59687a0..a7312a19e9 100644 --- a/boost/type_traits/has_nothrow_assign.hpp +++ b/boost/type_traits/has_nothrow_assign.hpp @@ -9,36 +9,75 @@ #ifndef BOOST_TT_HAS_NOTHROW_ASSIGN_HPP_INCLUDED #define BOOST_TT_HAS_NOTHROW_ASSIGN_HPP_INCLUDED -#include <boost/type_traits/has_trivial_assign.hpp> +#include <boost/type_traits/integral_constant.hpp> +#include <boost/type_traits/intrinsics.hpp> -// should be the last #include -#include <boost/type_traits/detail/bool_trait_def.hpp> +#if !defined(BOOST_HAS_NOTHROW_ASSIGN) || defined(BOOST_MSVC) || defined(BOOST_INTEL) +#include <boost/type_traits/has_trivial_assign.hpp> +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) +#include <boost/type_traits/declval.hpp> +#include <boost/type_traits/is_const.hpp> +#include <boost/type_traits/is_volatile.hpp> +#include <boost/type_traits/is_reference.hpp> +#include <boost/type_traits/is_assignable.hpp> +#include <boost/type_traits/add_reference.hpp> +#include <boost/type_traits/remove_reference.hpp> +#endif +#endif +#if defined(__GNUC__) || defined(__SUNPRO_CC) +#include <boost/type_traits/is_const.hpp> +#include <boost/type_traits/is_volatile.hpp> +#include <boost/type_traits/is_assignable.hpp> +#include <boost/type_traits/is_array.hpp> +#ifdef BOOST_INTEL +#include <boost/type_traits/is_pod.hpp> +#endif +#endif namespace boost { -namespace detail{ +#if !defined(BOOST_HAS_NOTHROW_ASSIGN) && !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + + namespace detail + { + template <class T, bool b1, bool b2> struct has_nothrow_assign_imp{ static const bool value = false; }; + template <class T> struct has_nothrow_assign_imp<T, false, true>{ static const bool value = noexcept(boost::declval<typename add_reference<T>::type>() = boost::declval<typename add_reference<T const>::type>()); }; + template <class T, std::size_t N> struct has_nothrow_assign_imp<T[N], false, true>{ static const bool value = has_nothrow_assign_imp<T, false, true>::value; }; + template <class T> struct has_nothrow_assign_imp<T[], false, true>{ static const bool value = has_nothrow_assign_imp<T, false, true>::value; }; + } -template <class T> -struct has_nothrow_assign_imp{ +#endif + + template <class T> + struct has_nothrow_assign : public integral_constant < bool, #ifndef BOOST_HAS_NOTHROW_ASSIGN - BOOST_STATIC_CONSTANT(bool, value = ::boost::has_trivial_assign<T>::value); +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + // Portable C++11 version: + detail::has_nothrow_assign_imp<T, + (is_const<typename remove_reference<T>::type>::value || is_volatile<typename remove_reference<T>::type>::value || is_reference<T>::value), + is_assignable<typename add_reference<T>::type, typename add_reference<const T>::type>::value + >::value #else - BOOST_STATIC_CONSTANT(bool, value = BOOST_HAS_NOTHROW_ASSIGN(T)); + ::boost::has_trivial_assign<T>::value #endif -}; - -} +#else + BOOST_HAS_NOTHROW_ASSIGN(T) +#endif + > {}; -BOOST_TT_AUX_BOOL_TRAIT_DEF1(has_nothrow_assign,T,::boost::detail::has_nothrow_assign_imp<T>::value) -BOOST_TT_AUX_BOOL_TRAIT_SPEC1(has_nothrow_assign,void,false) +template <class T, std::size_t N> struct has_nothrow_assign <T[N]> : public has_nothrow_assign<T> {}; +template <> struct has_nothrow_assign<void> : public false_type{}; +template <class T> struct has_nothrow_assign<T volatile> : public false_type{}; +template <class T> struct has_nothrow_assign<T&> : public false_type{}; +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) +template <class T> struct has_nothrow_assign<T&&> : public false_type{}; +#endif #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS -BOOST_TT_AUX_BOOL_TRAIT_SPEC1(has_nothrow_assign,void const,false) -BOOST_TT_AUX_BOOL_TRAIT_SPEC1(has_nothrow_assign,void const volatile,false) -BOOST_TT_AUX_BOOL_TRAIT_SPEC1(has_nothrow_assign,void volatile,false) +template <> struct has_nothrow_assign<void const> : public false_type{}; +template <> struct has_nothrow_assign<void const volatile> : public false_type{}; +template <> struct has_nothrow_assign<void volatile> : public false_type{}; #endif } // namespace boost -#include <boost/type_traits/detail/bool_trait_undef.hpp> - #endif // BOOST_TT_HAS_NOTHROW_ASSIGN_HPP_INCLUDED |