2 // (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
3 // Use, modification and distribution are subject to the Boost Software License,
4 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt).
7 // See http://www.boost.org/libs/type_traits for most recent version including documentation.
9 #ifndef BOOST_TT_HAS_NOTHROW_ASSIGN_HPP_INCLUDED
10 #define BOOST_TT_HAS_NOTHROW_ASSIGN_HPP_INCLUDED
12 #include <cstddef> // size_t
13 #include <boost/type_traits/integral_constant.hpp>
14 #include <boost/type_traits/intrinsics.hpp>
16 #if !defined(BOOST_HAS_NOTHROW_ASSIGN) || defined(BOOST_MSVC) || defined(BOOST_INTEL)
17 #include <boost/type_traits/has_trivial_assign.hpp>
18 #if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
19 #include <boost/type_traits/declval.hpp>
20 #include <boost/type_traits/is_const.hpp>
21 #include <boost/type_traits/is_volatile.hpp>
22 #include <boost/type_traits/is_reference.hpp>
23 #include <boost/type_traits/is_assignable.hpp>
24 #include <boost/type_traits/add_reference.hpp>
25 #include <boost/type_traits/remove_reference.hpp>
28 #if defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__clang__)
29 #include <boost/type_traits/is_const.hpp>
30 #include <boost/type_traits/is_volatile.hpp>
31 #include <boost/type_traits/is_assignable.hpp>
32 #include <boost/type_traits/is_array.hpp>
34 #include <boost/type_traits/is_pod.hpp>
40 #if !defined(BOOST_HAS_NOTHROW_ASSIGN) && !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
44 template <class T, bool b1, bool b2> struct has_nothrow_assign_imp{ static const bool value = false; };
45 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>()); };
46 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; };
47 template <class T> struct has_nothrow_assign_imp<T[], false, true>{ static const bool value = has_nothrow_assign_imp<T, false, true>::value; };
53 struct has_nothrow_assign : public integral_constant < bool,
54 #ifndef BOOST_HAS_NOTHROW_ASSIGN
55 #if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
56 // Portable C++11 version:
57 detail::has_nothrow_assign_imp<T,
58 (is_const<typename remove_reference<T>::type>::value || is_volatile<typename remove_reference<T>::type>::value || is_reference<T>::value),
59 is_assignable<typename add_reference<T>::type, typename add_reference<const T>::type>::value
62 ::boost::has_trivial_assign<T>::value
65 BOOST_HAS_NOTHROW_ASSIGN(T)
69 template <class T, std::size_t N> struct has_nothrow_assign <T[N]> : public has_nothrow_assign<T> {};
70 template <> struct has_nothrow_assign<void> : public false_type{};
71 template <class T> struct has_nothrow_assign<T volatile> : public false_type{};
72 template <class T> struct has_nothrow_assign<T&> : public false_type{};
73 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
74 template <class T> struct has_nothrow_assign<T&&> : public false_type{};
76 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
77 template <> struct has_nothrow_assign<void const> : public false_type{};
78 template <> struct has_nothrow_assign<void const volatile> : public false_type{};
79 template <> struct has_nothrow_assign<void volatile> : public false_type{};
84 #endif // BOOST_TT_HAS_NOTHROW_ASSIGN_HPP_INCLUDED