| 1 | |
| 2 | // (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000. |
| 3 | // (C) Copyright Eric Friedman 2002-2003. |
| 4 | // (C) Copyright Antony Polukhin 2013. |
| 5 | // Use, modification and distribution are subject to the Boost Software License, |
| 6 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
| 7 | // http://www.boost.org/LICENSE_1_0.txt). |
| 8 | // |
| 9 | // See http://www.boost.org/libs/type_traits for most recent version including documentation. |
| 10 | |
| 11 | #ifndef BOOST_TT_IS_NOTHROW_MOVE_CONSTRUCTIBLE_HPP_INCLUDED |
| 12 | #define BOOST_TT_IS_NOTHROW_MOVE_CONSTRUCTIBLE_HPP_INCLUDED |
| 13 | |
| 14 | #include <cstddef> // size_t |
| 15 | #include <boost/config.hpp> |
| 16 | #include <boost/type_traits/intrinsics.hpp> |
| 17 | #include <boost/type_traits/integral_constant.hpp> |
| 18 | #include <boost/detail/workaround.hpp> |
| 19 | #include <boost/type_traits/is_complete.hpp> |
| 20 | #include <boost/static_assert.hpp> |
| 21 | |
| 22 | #ifdef BOOST_IS_NOTHROW_MOVE_CONSTRUCT |
| 23 | |
| 24 | namespace boost { |
| 25 | |
| 26 | template <class T> |
| 27 | struct is_nothrow_move_constructible : public integral_constant<bool, BOOST_IS_NOTHROW_MOVE_CONSTRUCT(T)> |
| 28 | { |
| 29 | BOOST_STATIC_ASSERT_MSG(boost::is_complete<T>::value, "Arguments to is_nothrow_move_constructible must be complete types" ); |
| 30 | }; |
| 31 | |
| 32 | template <class T> struct is_nothrow_move_constructible<volatile T> : public ::boost::false_type {}; |
| 33 | template <class T> struct is_nothrow_move_constructible<const volatile T> : public ::boost::false_type{}; |
| 34 | |
| 35 | #elif !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) && !BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40700) |
| 36 | |
| 37 | #include <boost/type_traits/declval.hpp> |
| 38 | #include <boost/type_traits/enable_if.hpp> |
| 39 | |
| 40 | namespace boost{ namespace detail{ |
| 41 | |
| 42 | template <class T, class Enable = void> |
| 43 | struct false_or_cpp11_noexcept_move_constructible: public ::boost::false_type {}; |
| 44 | |
| 45 | template <class T> |
| 46 | struct false_or_cpp11_noexcept_move_constructible < |
| 47 | T, |
| 48 | typename ::boost::enable_if_<sizeof(T) && BOOST_NOEXCEPT_EXPR(T(::boost::declval<T>()))>::type |
| 49 | > : public ::boost::integral_constant<bool, BOOST_NOEXCEPT_EXPR(T(::boost::declval<T>()))> |
| 50 | {}; |
| 51 | |
| 52 | } |
| 53 | |
| 54 | template <class T> struct is_nothrow_move_constructible |
| 55 | : public integral_constant<bool, ::boost::detail::false_or_cpp11_noexcept_move_constructible<T>::value> |
| 56 | { |
| 57 | BOOST_STATIC_ASSERT_MSG(boost::is_complete<T>::value, "Arguments to is_nothrow_move_constructible must be complete types" ); |
| 58 | }; |
| 59 | |
| 60 | template <class T> struct is_nothrow_move_constructible<volatile T> : public ::boost::false_type {}; |
| 61 | template <class T> struct is_nothrow_move_constructible<const volatile T> : public ::boost::false_type{}; |
| 62 | template <class T, std::size_t N> struct is_nothrow_move_constructible<T[N]> : public ::boost::false_type{}; |
| 63 | template <class T> struct is_nothrow_move_constructible<T[]> : public ::boost::false_type{}; |
| 64 | |
| 65 | #else |
| 66 | |
| 67 | #include <boost/type_traits/has_trivial_move_constructor.hpp> |
| 68 | #include <boost/type_traits/has_nothrow_copy.hpp> |
| 69 | #include <boost/type_traits/is_array.hpp> |
| 70 | |
| 71 | namespace boost{ |
| 72 | |
| 73 | template <class T> |
| 74 | struct is_nothrow_move_constructible |
| 75 | : public integral_constant<bool, |
| 76 | (::boost::has_trivial_move_constructor<T>::value || ::boost::has_nothrow_copy<T>::value) && !::boost::is_array<T>::value> |
| 77 | { |
| 78 | BOOST_STATIC_ASSERT_MSG(boost::is_complete<T>::value, "Arguments to is_nothrow_move_constructible must be complete types" ); |
| 79 | }; |
| 80 | |
| 81 | #endif |
| 82 | |
| 83 | template <> struct is_nothrow_move_constructible<void> : false_type{}; |
| 84 | #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS |
| 85 | template <> struct is_nothrow_move_constructible<void const> : false_type{}; |
| 86 | template <> struct is_nothrow_move_constructible<void volatile> : false_type{}; |
| 87 | template <> struct is_nothrow_move_constructible<void const volatile> : false_type{}; |
| 88 | #endif |
| 89 | // References are always trivially constructible, even if the thing they reference is not: |
| 90 | template <class T> struct is_nothrow_move_constructible<T&> : public ::boost::true_type{}; |
| 91 | #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES |
| 92 | template <class T> struct is_nothrow_move_constructible<T&&> : public ::boost::true_type{}; |
| 93 | #endif |
| 94 | |
| 95 | } // namespace boost |
| 96 | |
| 97 | #endif // BOOST_TT_IS_NOTHROW_MOVE_CONSTRUCTIBLE_HPP_INCLUDED |
| 98 | |