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 <cstddef> // size_t
13#include <boost/type_traits/integral_constant.hpp>
14#include <boost/type_traits/intrinsics.hpp>
15
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>
26#endif
27#endif
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>
33#ifdef BOOST_INTEL
34#include <boost/type_traits/is_pod.hpp>
35#endif
36#endif
37
38namespace boost {
39
40#if !defined(BOOST_HAS_NOTHROW_ASSIGN) && !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
41
42 namespace detail
43 {
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; };
48 }
49
50#endif
51
52 template <class T>
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
60 >::value
61#else
62 ::boost::has_trivial_assign<T>::value
63#endif
64#else
65 BOOST_HAS_NOTHROW_ASSIGN(T)
66#endif
67 > {};
68
69template <class T, std::size_t N> struct has_nothrow_assign <T[N]> : public has_nothrow_assign<T> {};
70template <> struct has_nothrow_assign<void> : public false_type{};
71template <class T> struct has_nothrow_assign<T volatile> : public false_type{};
72template <class T> struct has_nothrow_assign<T&> : public false_type{};
73#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
74template <class T> struct has_nothrow_assign<T&&> : public false_type{};
75#endif
76#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
77template <> struct has_nothrow_assign<void const> : public false_type{};
78template <> struct has_nothrow_assign<void const volatile> : public false_type{};
79template <> struct has_nothrow_assign<void volatile> : public false_type{};
80#endif
81
82} // namespace boost
83
84#endif // BOOST_TT_HAS_NOTHROW_ASSIGN_HPP_INCLUDED
85

source code of include/boost/type_traits/has_nothrow_assign.hpp