is_nothrow_move_assignable.hpp 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
  2. // (C) Copyright Eric Friedman 2002-2003.
  3. // (C) Copyright Antony Polukhin 2013.
  4. // Use, modification and distribution are subject to the Boost Software License,
  5. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt).
  7. //
  8. // See http://www.boost.org/libs/type_traits for most recent version including documentation.
  9. #ifndef BOOST_TT_IS_NOTHROW_MOVE_ASSIGNABLE_HPP_INCLUDED
  10. #define BOOST_TT_IS_NOTHROW_MOVE_ASSIGNABLE_HPP_INCLUDED
  11. #include <boost/config.hpp>
  12. #include <boost/type_traits/has_trivial_move_assign.hpp>
  13. #include <boost/type_traits/has_nothrow_assign.hpp>
  14. #include <boost/type_traits/is_array.hpp>
  15. #include <boost/type_traits/is_reference.hpp>
  16. #include <boost/type_traits/enable_if.hpp>
  17. #include <boost/type_traits/declval.hpp>
  18. #include <boost/type_traits/is_complete.hpp>
  19. #include <boost/static_assert.hpp>
  20. namespace boost {
  21. #ifdef BOOST_IS_NOTHROW_MOVE_ASSIGN
  22. template <class T>
  23. struct is_nothrow_move_assignable : public integral_constant<bool, BOOST_IS_NOTHROW_MOVE_ASSIGN(T)>
  24. {
  25. BOOST_STATIC_ASSERT_MSG(boost::is_complete<T>::value, "Arguments to is_nothrow_move_assignable must be complete types");
  26. };
  27. template <class T> struct is_nothrow_move_assignable<T const> : public false_type{};
  28. template <class T> struct is_nothrow_move_assignable<T volatile> : public false_type{};
  29. template <class T> struct is_nothrow_move_assignable<T const volatile> : public false_type{};
  30. template <class T> struct is_nothrow_move_assignable<T&> : public false_type{};
  31. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  32. template <class T> struct is_nothrow_move_assignable<T&&> : public false_type{};
  33. #endif
  34. #elif !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) && !BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40700)
  35. namespace detail{
  36. template <class T, class Enable = void>
  37. struct false_or_cpp11_noexcept_move_assignable: public ::boost::false_type {};
  38. template <class T>
  39. struct false_or_cpp11_noexcept_move_assignable <
  40. T,
  41. typename ::boost::enable_if_<sizeof(T) && BOOST_NOEXCEPT_EXPR(::boost::declval<T&>() = ::boost::declval<T>())>::type
  42. > : public ::boost::integral_constant<bool, BOOST_NOEXCEPT_EXPR(::boost::declval<T&>() = ::boost::declval<T>())>
  43. {};
  44. }
  45. template <class T>
  46. struct is_nothrow_move_assignable : public integral_constant<bool, ::boost::detail::false_or_cpp11_noexcept_move_assignable<T>::value>
  47. {
  48. BOOST_STATIC_ASSERT_MSG(boost::is_complete<T>::value, "Arguments to is_nothrow_move_assignable must be complete types");
  49. };
  50. template <class T> struct is_nothrow_move_assignable<T const> : public ::boost::false_type {};
  51. template <class T> struct is_nothrow_move_assignable<T const volatile> : public ::boost::false_type{};
  52. template <class T> struct is_nothrow_move_assignable<T volatile> : public ::boost::false_type{};
  53. template <class T> struct is_nothrow_move_assignable<T&> : public ::boost::false_type{};
  54. #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
  55. template <class T> struct is_nothrow_move_assignable<T&&> : public ::boost::false_type{};
  56. #endif
  57. #else
  58. template <class T>
  59. struct is_nothrow_move_assignable : public integral_constant<bool,
  60. (::boost::has_trivial_move_assign<T>::value || ::boost::has_nothrow_assign<T>::value) && ! ::boost::is_array<T>::value>
  61. {
  62. BOOST_STATIC_ASSERT_MSG(boost::is_complete<T>::value, "Arguments to is_nothrow_move_assignable must be complete types");
  63. };
  64. #endif
  65. template <> struct is_nothrow_move_assignable<void> : public false_type{};
  66. #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
  67. template <> struct is_nothrow_move_assignable<void const> : public false_type{};
  68. template <> struct is_nothrow_move_assignable<void const volatile> : public false_type{};
  69. template <> struct is_nothrow_move_assignable<void volatile> : public false_type{};
  70. #endif
  71. } // namespace boost
  72. #endif // BOOST_TT_IS_NOTHROW_MOVE_ASSIGNABLE_HPP_INCLUDED