has_trivial_move_constructor.hpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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_HAS_TRIVIAL_MOVE_CONSTRUCTOR_HPP_INCLUDED
  10. #define BOOST_TT_HAS_TRIVIAL_MOVE_CONSTRUCTOR_HPP_INCLUDED
  11. #include <cstddef> // size_t
  12. #include <boost/type_traits/intrinsics.hpp>
  13. #include <boost/type_traits/integral_constant.hpp>
  14. #ifdef BOOST_HAS_TRIVIAL_MOVE_CONSTRUCTOR
  15. #if defined(BOOST_MSVC) || defined(BOOST_INTEL)
  16. #include <boost/type_traits/is_pod.hpp>
  17. #include <boost/type_traits/is_volatile.hpp>
  18. #include <boost/type_traits/is_reference.hpp>
  19. #endif
  20. #if defined(__GNUC__) || defined(__clang__)
  21. #include <boost/type_traits/is_constructible.hpp>
  22. #include <boost/type_traits/is_volatile.hpp>
  23. #endif
  24. namespace boost {
  25. template <typename T> struct has_trivial_move_constructor : public integral_constant<bool, BOOST_HAS_TRIVIAL_MOVE_CONSTRUCTOR(T)>{};
  26. #else
  27. #ifdef __SUNPRO_CC
  28. #include <boost/type_traits/is_constructible.hpp>
  29. #include <boost/type_traits/remove_const.hpp>
  30. #if __cplusplus >= 201103
  31. #define SOLARIS_EXTRA_CHECK && is_constructible<typename remove_const<T>::type, typename remove_const<T>::type&&>::value
  32. #endif
  33. #endif
  34. #ifndef SOLARIS_EXTRA_CHECK
  35. #define SOLARIS_EXTRA_CHECK
  36. #endif
  37. #include <boost/type_traits/is_pod.hpp>
  38. #include <boost/type_traits/is_volatile.hpp>
  39. namespace boost {
  40. template <typename T> struct has_trivial_move_constructor
  41. : public integral_constant<bool, ::boost::is_pod<T>::value && !::boost::is_volatile<T>::value SOLARIS_EXTRA_CHECK>{};
  42. #undef SOLARIS_EXTRA_CHECK
  43. #endif
  44. template <> struct has_trivial_move_constructor<void> : public false_type{};
  45. #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
  46. template <> struct has_trivial_move_constructor<void const> : public false_type{};
  47. template <> struct has_trivial_move_constructor<void volatile> : public false_type{};
  48. template <> struct has_trivial_move_constructor<void const volatile> : public false_type{};
  49. #endif
  50. // What should we do with reference types??? The standard seems to suggest these are trivial, even if the thing they reference is not:
  51. template <class T> struct has_trivial_move_constructor<T&> : public true_type{};
  52. #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
  53. template <class T> struct has_trivial_move_constructor<T&&> : public true_type{};
  54. #endif
  55. // Arrays can not be explicitly copied:
  56. template <class T, std::size_t N> struct has_trivial_move_constructor<T[N]> : public false_type{};
  57. template <class T> struct has_trivial_move_constructor<T[]> : public false_type{};
  58. } // namespace boost
  59. #endif // BOOST_TT_HAS_TRIVIAL_MOVE_CONSTRUCTOR_HPP_INCLUDED