has_nothrow_copy.hpp 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
  2. // Use, modification and distribution are subject to the Boost Software License,
  3. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt).
  5. //
  6. // See http://www.boost.org/libs/type_traits for most recent version including documentation.
  7. #ifndef BOOST_TT_HAS_NOTHROW_COPY_HPP_INCLUDED
  8. #define BOOST_TT_HAS_NOTHROW_COPY_HPP_INCLUDED
  9. #include <boost/type_traits/intrinsics.hpp>
  10. #include <boost/type_traits/integral_constant.hpp>
  11. #ifdef BOOST_HAS_NOTHROW_COPY
  12. #if defined(BOOST_CLANG) || defined(__GNUC__) || defined(__ghs__) || defined(__CODEGEARC__) || defined(__SUNPRO_CC)
  13. #include <boost/type_traits/is_volatile.hpp>
  14. #include <boost/type_traits/is_copy_constructible.hpp>
  15. #include <boost/type_traits/is_reference.hpp>
  16. #include <boost/type_traits/is_array.hpp>
  17. #ifdef BOOST_INTEL
  18. #include <boost/type_traits/is_pod.hpp>
  19. #endif
  20. #elif defined(BOOST_MSVC) || defined(BOOST_INTEL)
  21. #include <boost/type_traits/has_trivial_copy.hpp>
  22. #include <boost/type_traits/is_array.hpp>
  23. #ifdef BOOST_INTEL
  24. #include <boost/type_traits/add_lvalue_reference.hpp>
  25. #include <boost/type_traits/add_const.hpp>
  26. #endif
  27. #endif
  28. namespace boost {
  29. template <class T> struct has_nothrow_copy_constructor : public integral_constant<bool, BOOST_HAS_NOTHROW_COPY(T)>{};
  30. #elif !defined(BOOST_NO_CXX11_NOEXCEPT)
  31. #include <boost/type_traits/declval.hpp>
  32. #include <boost/type_traits/is_copy_constructible.hpp>
  33. namespace boost{
  34. namespace detail{
  35. template <class T, bool b>
  36. struct has_nothrow_copy_constructor_imp : public boost::integral_constant<bool, false>{};
  37. template <class T>
  38. struct has_nothrow_copy_constructor_imp<T, true> : public boost::integral_constant<bool, noexcept(T(boost::declval<const T&>()))>{};
  39. }
  40. template <class T> struct has_nothrow_copy_constructor : public detail::has_nothrow_copy_constructor_imp<T, boost::is_copy_constructible<T>::value>{};
  41. #else
  42. #include <boost/type_traits/has_trivial_copy.hpp>
  43. namespace boost{
  44. template <class T> struct has_nothrow_copy_constructor : public integral_constant<bool, ::boost::has_trivial_copy<T>::value>{};
  45. #endif
  46. template <> struct has_nothrow_copy_constructor<void> : public false_type{};
  47. template <class T> struct has_nothrow_copy_constructor<T volatile> : public false_type{};
  48. template <class T> struct has_nothrow_copy_constructor<T&> : public false_type{};
  49. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  50. template <class T> struct has_nothrow_copy_constructor<T&&> : public false_type{};
  51. #endif
  52. #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
  53. template <> struct has_nothrow_copy_constructor<void const> : public false_type{};
  54. template <> struct has_nothrow_copy_constructor<void volatile> : public false_type{};
  55. template <> struct has_nothrow_copy_constructor<void const volatile> : public false_type{};
  56. #endif
  57. template <class T> struct has_nothrow_copy : public has_nothrow_copy_constructor<T>{};
  58. } // namespace boost
  59. #endif // BOOST_TT_HAS_NOTHROW_COPY_HPP_INCLUDED