experimental_traits.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright (C) 2017 Andrzej Krzemienski.
  2. //
  3. // Use, modification, and distribution is subject to the Boost Software
  4. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/optional for documentation.
  8. //
  9. // You are welcome to contact the author at:
  10. // akrzemi1@gmail.com
  11. #ifndef BOOST_OPTIONAL_DETAIL_EXPERIMENTAL_TRAITS_04NOV2017_HPP
  12. #define BOOST_OPTIONAL_DETAIL_EXPERIMENTAL_TRAITS_04NOV2017_HPP
  13. #include <boost/type_traits.hpp>
  14. // The condition to use POD implementation
  15. #ifdef BOOST_OPTIONAL_CONFIG_NO_POD_SPEC
  16. # define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
  17. #elif defined BOOST_OPTIONAL_CONFIG_NO_SPEC_FOR_TRIVIAL_TYPES
  18. # define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
  19. #elif !defined BOOST_HAS_TRIVIAL_MOVE_ASSIGN
  20. # define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
  21. #elif !defined BOOST_HAS_TRIVIAL_MOVE_CONSTRUCTOR
  22. # define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
  23. #elif !defined BOOST_HAS_TRIVIAL_COPY
  24. # define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
  25. #elif !defined BOOST_HAS_TRIVIAL_ASSIGN
  26. # define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
  27. #elif !defined BOOST_HAS_TRIVIAL_DESTRUCTOR
  28. # define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
  29. #endif
  30. namespace boost { namespace optional_detail {
  31. #ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
  32. template <typename T>
  33. struct is_trivially_semiregular
  34. : boost::conditional<(boost::has_trivial_copy_constructor<T>::value &&
  35. boost::has_trivial_move_constructor<T>::value &&
  36. boost::has_trivial_destructor<T>::value &&
  37. boost::has_trivial_move_assign<T>::value &&
  38. boost::has_trivial_assign<T>::value),
  39. boost::true_type, boost::false_type>::type
  40. {};
  41. #else
  42. template <typename T>
  43. struct is_trivially_semiregular
  44. : boost::conditional<(boost::is_scalar<T>::value && !boost::is_const<T>::value && !boost::is_volatile<T>::value),
  45. boost::true_type, boost::false_type>::type
  46. {};
  47. #endif
  48. }} // boost::optional_detail
  49. #endif