has_trivial_assign.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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_TRIVIAL_ASSIGN_HPP_INCLUDED
  8. #define BOOST_TT_HAS_TRIVIAL_ASSIGN_HPP_INCLUDED
  9. #include <cstddef> // size_t
  10. #include <boost/type_traits/detail/config.hpp>
  11. #include <boost/type_traits/intrinsics.hpp>
  12. #include <boost/type_traits/integral_constant.hpp>
  13. #if !defined(BOOST_HAS_TRIVIAL_ASSIGN) || defined(BOOST_MSVC) || defined(__GNUC__) || defined(BOOST_INTEL) || defined(__SUNPRO_CC) || defined(__clang__)
  14. #include <boost/type_traits/is_pod.hpp>
  15. #include <boost/type_traits/is_const.hpp>
  16. #include <boost/type_traits/is_volatile.hpp>
  17. #include <boost/type_traits/is_assignable.hpp>
  18. #endif
  19. namespace boost {
  20. template <typename T>
  21. struct has_trivial_assign : public integral_constant < bool,
  22. #ifdef BOOST_HAS_TRIVIAL_ASSIGN
  23. BOOST_HAS_TRIVIAL_ASSIGN(T)
  24. #else
  25. ::boost::is_pod<T>::value && !::boost::is_const<T>::value && !::boost::is_volatile<T>::value
  26. #endif
  27. > {};
  28. template<> struct has_trivial_assign<void> : public false_type{};
  29. #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
  30. template<> struct has_trivial_assign<void const> : public false_type{};
  31. template<> struct has_trivial_assign<void const volatile> : public false_type{};
  32. template<> struct has_trivial_assign<void volatile> : public false_type{};
  33. #endif
  34. template <class T> struct has_trivial_assign<T volatile> : public false_type{};
  35. template <class T> struct has_trivial_assign<T&> : public false_type{};
  36. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  37. template <class T> struct has_trivial_assign<T&&> : public false_type{};
  38. #endif
  39. // Arrays are not explictly assignable:
  40. template <typename T, std::size_t N> struct has_trivial_assign<T[N]> : public false_type{};
  41. template <typename T> struct has_trivial_assign<T[]> : public false_type{};
  42. } // namespace boost
  43. #endif // BOOST_TT_HAS_TRIVIAL_ASSIGN_HPP_INCLUDED