mpl.hpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2005-2013.
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/container for documentation.
  10. //
  11. //////////////////////////////////////////////////////////////////////////////
  12. #ifndef BOOST_CONTAINER_CONTAINER_DETAIL_MPL_HPP
  13. #define BOOST_CONTAINER_CONTAINER_DETAIL_MPL_HPP
  14. #ifndef BOOST_CONFIG_HPP
  15. # include <boost/config.hpp>
  16. #endif
  17. #if defined(BOOST_HAS_PRAGMA_ONCE)
  18. # pragma once
  19. #endif
  20. #include <boost/container/detail/config_begin.hpp>
  21. #include <boost/container/detail/workaround.hpp>
  22. #include <boost/move/detail/type_traits.hpp>
  23. #include <boost/intrusive/detail/mpl.hpp>
  24. #include <cstddef>
  25. namespace boost {
  26. namespace container {
  27. namespace dtl {
  28. using boost::move_detail::integral_constant;
  29. using boost::move_detail::true_type;
  30. using boost::move_detail::false_type;
  31. using boost::move_detail::enable_if_c;
  32. using boost::move_detail::enable_if;
  33. using boost::move_detail::enable_if_convertible;
  34. using boost::move_detail::disable_if_c;
  35. using boost::move_detail::disable_if;
  36. using boost::move_detail::disable_if_convertible;
  37. using boost::move_detail::is_convertible;
  38. using boost::move_detail::if_c;
  39. using boost::move_detail::if_;
  40. using boost::move_detail::identity;
  41. using boost::move_detail::bool_;
  42. using boost::move_detail::true_;
  43. using boost::move_detail::false_;
  44. using boost::move_detail::yes_type;
  45. using boost::move_detail::no_type;
  46. using boost::move_detail::bool_;
  47. using boost::move_detail::true_;
  48. using boost::move_detail::false_;
  49. using boost::move_detail::unvoid_ref;
  50. using boost::move_detail::and_;
  51. using boost::move_detail::or_;
  52. using boost::move_detail::not_;
  53. using boost::move_detail::enable_if_and;
  54. using boost::move_detail::disable_if_and;
  55. using boost::move_detail::enable_if_or;
  56. using boost::move_detail::disable_if_or;
  57. using boost::move_detail::remove_const;
  58. template <class FirstType>
  59. struct select1st
  60. {
  61. typedef FirstType type;
  62. template<class T>
  63. BOOST_CONTAINER_FORCEINLINE const type& operator()(const T& x) const
  64. { return x.first; }
  65. template<class T>
  66. BOOST_CONTAINER_FORCEINLINE type& operator()(T& x)
  67. { return const_cast<type&>(x.first); }
  68. };
  69. template<typename T>
  70. struct void_t { typedef void type; };
  71. template <class T, class=void>
  72. struct is_transparent_base
  73. {
  74. static const bool value = false;
  75. };
  76. template <class T>
  77. struct is_transparent_base<T, typename void_t<typename T::is_transparent>::type>
  78. {
  79. static const bool value = true;
  80. };
  81. template <class T>
  82. struct is_transparent
  83. : is_transparent_base<T>
  84. {};
  85. template <typename C, class /*Dummy*/, typename R>
  86. struct enable_if_transparent
  87. : boost::move_detail::enable_if_c<dtl::is_transparent<C>::value, R>
  88. {};
  89. #ifndef BOOST_CONTAINER_NO_CXX17_CTAD
  90. // void_t (void_t for C++11)
  91. template<typename...> using variadic_void_t = void;
  92. // Trait to detect Allocator-like types.
  93. template<typename Allocator, typename = void>
  94. struct is_allocator
  95. {
  96. static const bool value = false;
  97. };
  98. template <typename T>
  99. T&& ctad_declval();
  100. template<typename Allocator>
  101. struct is_allocator < Allocator,
  102. variadic_void_t< typename Allocator::value_type
  103. , decltype(ctad_declval<Allocator&>().allocate(size_t{})) >>
  104. {
  105. static const bool value = true;
  106. };
  107. template<class T>
  108. using require_allocator_t = typename enable_if_c<is_allocator<T>::value, T>::type;
  109. template<class T>
  110. using require_nonallocator_t = typename enable_if_c<!is_allocator<T>::value, T>::type;
  111. #endif
  112. } //namespace dtl {
  113. } //namespace container {
  114. } //namespace boost {
  115. #include <boost/container/detail/config_end.hpp>
  116. #endif //#ifndef BOOST_CONTAINER_CONTAINER_DETAIL_MPL_HPP