1 | |
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). |
6 | // |
7 | // See http://www.boost.org/libs/type_traits for most recent version including documentation. |
8 | |
9 | #ifndef BOOST_TT_HAS_NOTHROW_ASSIGN_HPP_INCLUDED |
10 | #define BOOST_TT_HAS_NOTHROW_ASSIGN_HPP_INCLUDED |
11 | |
12 | #include <boost/type_traits/integral_constant.hpp> |
13 | #include <boost/type_traits/intrinsics.hpp> |
14 | |
15 | #if !defined(BOOST_HAS_NOTHROW_ASSIGN) || defined(BOOST_MSVC) || defined(BOOST_INTEL) |
16 | #include <boost/type_traits/has_trivial_assign.hpp> |
17 | #if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) |
18 | #include <boost/type_traits/declval.hpp> |
19 | #include <boost/type_traits/is_const.hpp> |
20 | #include <boost/type_traits/is_volatile.hpp> |
21 | #include <boost/type_traits/is_reference.hpp> |
22 | #include <boost/type_traits/is_assignable.hpp> |
23 | #include <boost/type_traits/add_reference.hpp> |
24 | #include <boost/type_traits/remove_reference.hpp> |
25 | #endif |
26 | #endif |
27 | #if defined(__GNUC__) || defined(__SUNPRO_CC) |
28 | #include <boost/type_traits/is_const.hpp> |
29 | #include <boost/type_traits/is_volatile.hpp> |
30 | #include <boost/type_traits/is_assignable.hpp> |
31 | #include <boost/type_traits/is_array.hpp> |
32 | #ifdef BOOST_INTEL |
33 | #include <boost/type_traits/is_pod.hpp> |
34 | #endif |
35 | #endif |
36 | |
37 | namespace boost { |
38 | |
39 | #if !defined(BOOST_HAS_NOTHROW_ASSIGN) && !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) |
40 | |
41 | namespace detail |
42 | { |
43 | template <class T, bool b1, bool b2> struct has_nothrow_assign_imp{ static const bool value = false; }; |
44 | 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>()); }; |
45 | 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; }; |
46 | template <class T> struct has_nothrow_assign_imp<T[], false, true>{ static const bool value = has_nothrow_assign_imp<T, false, true>::value; }; |
47 | } |
48 | |
49 | #endif |
50 | |
51 | template <class T> |
52 | struct has_nothrow_assign : public integral_constant < bool, |
53 | #ifndef BOOST_HAS_NOTHROW_ASSIGN |
54 | #if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) |
55 | // Portable C++11 version: |
56 | detail::has_nothrow_assign_imp<T, |
57 | (is_const<typename remove_reference<T>::type>::value || is_volatile<typename remove_reference<T>::type>::value || is_reference<T>::value), |
58 | is_assignable<typename add_reference<T>::type, typename add_reference<const T>::type>::value |
59 | >::value |
60 | #else |
61 | ::boost::has_trivial_assign<T>::value |
62 | #endif |
63 | #else |
64 | BOOST_HAS_NOTHROW_ASSIGN(T) |
65 | #endif |
66 | > {}; |
67 | |
68 | template <class T, std::size_t N> struct has_nothrow_assign <T[N]> : public has_nothrow_assign<T> {}; |
69 | template <> struct has_nothrow_assign<void> : public false_type{}; |
70 | template <class T> struct has_nothrow_assign<T volatile> : public false_type{}; |
71 | template <class T> struct has_nothrow_assign<T&> : public false_type{}; |
72 | #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) |
73 | template <class T> struct has_nothrow_assign<T&&> : public false_type{}; |
74 | #endif |
75 | #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS |
76 | template <> struct has_nothrow_assign<void const> : public false_type{}; |
77 | template <> struct has_nothrow_assign<void const volatile> : public false_type{}; |
78 | template <> struct has_nothrow_assign<void volatile> : public false_type{}; |
79 | #endif |
80 | |
81 | } // namespace boost |
82 | |
83 | #endif // BOOST_TT_HAS_NOTHROW_ASSIGN_HPP_INCLUDED |
84 | |