pair.hpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  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_PAIR_HPP
  13. #define BOOST_CONTAINER_CONTAINER_DETAIL_PAIR_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/container_fwd.hpp>
  22. #include <boost/container/detail/workaround.hpp>
  23. #include <boost/static_assert.hpp>
  24. #include <boost/container/detail/mpl.hpp>
  25. #include <boost/container/detail/type_traits.hpp>
  26. #include <boost/container/detail/mpl.hpp>
  27. #include <boost/container/detail/std_fwd.hpp>
  28. #include <boost/container/detail/is_pair.hpp>
  29. #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  30. # include <boost/container/detail/variadic_templates_tools.hpp>
  31. #endif
  32. #include <boost/move/adl_move_swap.hpp> //swap
  33. #include <boost/intrusive/detail/minimal_pair_header.hpp> //pair
  34. #include <boost/move/utility_core.hpp>
  35. #include <boost/move/detail/fwd_macros.hpp>
  36. namespace boost {
  37. namespace container {
  38. namespace pair_impl {
  39. template <class TupleClass>
  40. struct is_boost_tuple
  41. {
  42. static const bool value = false;
  43. };
  44. template <
  45. class T0, class T1, class T2,
  46. class T3, class T4, class T5,
  47. class T6, class T7, class T8,
  48. class T9>
  49. struct is_boost_tuple< boost::tuples::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> >
  50. {
  51. static const bool value = true;
  52. };
  53. template<class Tuple>
  54. struct disable_if_boost_tuple
  55. : boost::container::dtl::disable_if< is_boost_tuple<Tuple> >
  56. {};
  57. template<class T>
  58. struct is_tuple_null
  59. {
  60. static const bool value = false;
  61. };
  62. template<>
  63. struct is_tuple_null<boost::tuples::null_type>
  64. {
  65. static const bool value = true;
  66. };
  67. } //namespace detail {
  68. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  69. template <int Dummy = 0>
  70. struct std_piecewise_construct_holder
  71. {
  72. static ::std::piecewise_construct_t *dummy;
  73. };
  74. template <int Dummy>
  75. ::std::piecewise_construct_t *std_piecewise_construct_holder<Dummy>::dummy =
  76. reinterpret_cast< ::std::piecewise_construct_t *>(0x01234); //Avoid sanitizer errors on references to null pointers
  77. #else
  78. //! The piecewise_construct_t struct is an empty structure type used as a unique type to
  79. //! disambiguate used to disambiguate between different functions that take two tuple arguments.
  80. typedef unspecified piecewise_construct_t;
  81. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  82. //! A instance of type
  83. //! piecewise_construct_t
  84. static piecewise_construct_t piecewise_construct = BOOST_CONTAINER_DOC1ST(unspecified, *std_piecewise_construct_holder<>::dummy);
  85. ///@cond
  86. namespace dtl {
  87. struct piecewise_construct_use
  88. {
  89. //Avoid warnings of unused "piecewise_construct"
  90. piecewise_construct_use()
  91. { (void)&::boost::container::piecewise_construct; }
  92. };
  93. struct pair_nat;
  94. template<typename T, typename U, typename V>
  95. void get(T); //to enable ADL
  96. ///@endcond
  97. #ifdef _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
  98. //Libc++, in some versions, has an ABI breakage that needs some
  99. //padding in dtl::pair, as "std::pair::first" is not at offset zero.
  100. //See: https://reviews.llvm.org/D56357 for more information.
  101. //
  102. template <class T1, class T2, std::size_t N>
  103. struct pair_padding
  104. {
  105. char padding[N];
  106. };
  107. template <class T1, class T2>
  108. struct pair_padding<T1, T2, 0>
  109. {
  110. };
  111. template <class T1, class T2>
  112. struct simple_pair
  113. {
  114. T1 first;
  115. T2 second;
  116. };
  117. #endif
  118. template <class T1, class T2>
  119. struct pair
  120. #ifdef _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
  121. : pair_padding<T1, T2, sizeof(std::pair<T1, T2>) - sizeof(simple_pair<T1, T2>)>
  122. #endif
  123. {
  124. private:
  125. BOOST_COPYABLE_AND_MOVABLE(pair)
  126. public:
  127. typedef T1 first_type;
  128. typedef T2 second_type;
  129. T1 first;
  130. T2 second;
  131. //Default constructor
  132. pair()
  133. : first(), second()
  134. {
  135. BOOST_STATIC_ASSERT((sizeof(std::pair<T1, T2>) == sizeof(pair<T1, T2>)));
  136. }
  137. //pair copy assignment
  138. pair(const pair& x)
  139. : first(x.first), second(x.second)
  140. {
  141. BOOST_STATIC_ASSERT((sizeof(std::pair<T1, T2>) == sizeof(pair<T1, T2>)));
  142. }
  143. //pair move constructor
  144. pair(BOOST_RV_REF(pair) p)
  145. : first(::boost::move(BOOST_MOVE_TO_LV(p).first)), second(::boost::move(BOOST_MOVE_TO_LV(p).second))
  146. {
  147. BOOST_STATIC_ASSERT((sizeof(std::pair<T1, T2>) == sizeof(pair<T1, T2>)));
  148. }
  149. template <class D, class S>
  150. pair(const pair<D, S> &p)
  151. : first(p.first), second(p.second)
  152. {
  153. BOOST_STATIC_ASSERT((sizeof(std::pair<T1, T2>) == sizeof(pair<T1, T2>)));
  154. }
  155. template <class D, class S>
  156. pair(BOOST_RV_REF_BEG pair<D, S> BOOST_RV_REF_END p)
  157. : first(::boost::move(BOOST_MOVE_TO_LV(p).first)), second(::boost::move(BOOST_MOVE_TO_LV(p).second))
  158. {
  159. BOOST_STATIC_ASSERT((sizeof(std::pair<T1, T2>) == sizeof(pair<T1, T2>)));
  160. }
  161. //pair from two values
  162. pair(const T1 &t1, const T2 &t2)
  163. : first(t1)
  164. , second(t2)
  165. {
  166. BOOST_STATIC_ASSERT((sizeof(std::pair<T1, T2>) == sizeof(pair<T1, T2>)));
  167. }
  168. template<class U, class V>
  169. pair(BOOST_FWD_REF(U) u, BOOST_FWD_REF(V) v)
  170. : first(::boost::forward<U>(u))
  171. , second(::boost::forward<V>(v))
  172. {
  173. BOOST_STATIC_ASSERT((sizeof(std::pair<T1, T2>) == sizeof(pair<T1, T2>)));
  174. }
  175. //And now compatibility with std::pair
  176. pair(const std::pair<T1, T2>& x)
  177. : first(x.first), second(x.second)
  178. {
  179. BOOST_STATIC_ASSERT((sizeof(std::pair<T1, T2>) == sizeof(pair<T1, T2>)));
  180. }
  181. template <class D, class S>
  182. pair(const std::pair<D, S>& p)
  183. : first(p.first), second(p.second)
  184. {
  185. BOOST_STATIC_ASSERT((sizeof(std::pair<T1, T2>) == sizeof(pair<T1, T2>)));
  186. }
  187. pair(BOOST_RV_REF_BEG std::pair<T1, T2> BOOST_RV_REF_END p)
  188. : first(::boost::move(BOOST_MOVE_TO_LV(p).first)), second(::boost::move(BOOST_MOVE_TO_LV(p).second))
  189. {
  190. BOOST_STATIC_ASSERT((sizeof(std::pair<T1, T2>) == sizeof(pair<T1, T2>)));
  191. }
  192. template <class D, class S>
  193. pair(BOOST_RV_REF_BEG std::pair<D, S> BOOST_RV_REF_END p)
  194. : first(::boost::move(BOOST_MOVE_TO_LV(p).first)), second(::boost::move(BOOST_MOVE_TO_LV(p).second))
  195. {
  196. BOOST_STATIC_ASSERT((sizeof(std::pair<T1, T2>) == sizeof(pair<T1, T2>)));
  197. }
  198. #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  199. template< class KeyType, class ...Args>
  200. pair(try_emplace_t, BOOST_FWD_REF(KeyType) k, Args && ...args)
  201. : first(boost::forward<KeyType>(k)), second(::boost::forward<Args>(args)...)\
  202. {
  203. BOOST_STATIC_ASSERT((sizeof(std::pair<T1, T2>) == sizeof(pair<T1, T2>)));
  204. }
  205. #else
  206. //piecewise construction from boost::tuple
  207. #define BOOST_PAIR_TRY_EMPLACE_CONSTRUCT_CODE(N)\
  208. template< class KeyType BOOST_MOVE_I##N BOOST_MOVE_CLASS##N > \
  209. pair( try_emplace_t, BOOST_FWD_REF(KeyType) k BOOST_MOVE_I##N BOOST_MOVE_UREF##N )\
  210. : first(boost::forward<KeyType>(k)), second(BOOST_MOVE_FWD##N)\
  211. {\
  212. BOOST_STATIC_ASSERT((sizeof(std::pair<T1, T2>) == sizeof(pair<T1, T2>)));\
  213. }\
  214. //
  215. BOOST_MOVE_ITERATE_0TO9(BOOST_PAIR_TRY_EMPLACE_CONSTRUCT_CODE)
  216. #undef BOOST_PAIR_TRY_EMPLACE_CONSTRUCT_CODE
  217. #endif //BOOST_NO_CXX11_VARIADIC_TEMPLATES
  218. //piecewise construction from boost::tuple
  219. #define BOOST_PAIR_PIECEWISE_CONSTRUCT_BOOST_TUPLE_CODE(N,M)\
  220. template< template<class, class, class, class, class, class, class, class, class, class> class BoostTuple \
  221. BOOST_MOVE_I_IF(BOOST_MOVE_OR(N,M)) BOOST_MOVE_CLASS##N BOOST_MOVE_I_IF(BOOST_MOVE_AND(N,M)) BOOST_MOVE_CLASSQ##M > \
  222. pair( piecewise_construct_t\
  223. , BoostTuple<BOOST_MOVE_TARG##N BOOST_MOVE_I##N BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,N),::boost::tuples::null_type)> p\
  224. , BoostTuple<BOOST_MOVE_TARGQ##M BOOST_MOVE_I##M BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,M),::boost::tuples::null_type)> q\
  225. , typename dtl::enable_if_c\
  226. < pair_impl::is_boost_tuple< BoostTuple<BOOST_MOVE_TARG##N BOOST_MOVE_I##N BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,N),::boost::tuples::null_type)> >::value &&\
  227. !(pair_impl::is_tuple_null<BOOST_MOVE_LAST_TARG##N>::value || pair_impl::is_tuple_null<BOOST_MOVE_LAST_TARGQ##M>::value) \
  228. >::type* = 0\
  229. )\
  230. : first(BOOST_MOVE_TMPL_GET##N), second(BOOST_MOVE_TMPL_GETQ##M)\
  231. { (void)p; (void)q;\
  232. BOOST_STATIC_ASSERT((sizeof(std::pair<T1, T2>) == sizeof(pair<T1, T2>)));\
  233. }\
  234. //
  235. BOOST_MOVE_ITER2D_0TOMAX(9, BOOST_PAIR_PIECEWISE_CONSTRUCT_BOOST_TUPLE_CODE)
  236. #undef BOOST_PAIR_PIECEWISE_CONSTRUCT_BOOST_TUPLE_CODE
  237. //piecewise construction from variadic tuple (with delegating constructors)
  238. #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  239. # if !defined(BOOST_CONTAINER_NO_CXX11_DELEGATING_CONSTRUCTORS)
  240. private:
  241. template<template<class ...> class Tuple, class... Args1, class... Args2, size_t... Indexes1, size_t... Indexes2>
  242. pair(Tuple<Args1...>& t1, Tuple<Args2...>& t2, index_tuple<Indexes1...>, index_tuple<Indexes2...>)
  243. : first (::boost::forward<Args1>(get<Indexes1>(t1))...)
  244. , second(::boost::forward<Args2>(get<Indexes2>(t2))...)
  245. { (void) t1; (void)t2; }
  246. public:
  247. template< template<class ...> class Tuple, class... Args1, class... Args2
  248. , class = typename pair_impl::disable_if_boost_tuple< Tuple<Args1...> >::type>
  249. pair(piecewise_construct_t, Tuple<Args1...> t1, Tuple<Args2...> t2)
  250. : pair(t1, t2, typename build_number_seq<sizeof...(Args1)>::type(), typename build_number_seq<sizeof...(Args2)>::type())
  251. {
  252. BOOST_STATIC_ASSERT((sizeof(std::pair<T1, T2>) == sizeof(pair<T1, T2>)));
  253. }
  254. # else
  255. //piecewise construction from variadic tuple (suboptimal, without delegating constructors)
  256. private:
  257. template<typename T, template<class ...> class Tuple, typename... Args>
  258. static T build_from_args(Tuple<Args...>&& t)
  259. { return do_build_from_args<T>(::boost::move(t), typename build_number_seq<sizeof...(Args)>::type()); }
  260. template<typename T, template<class ...> class Tuple, typename... Args, std::size_t... Indexes>
  261. static T do_build_from_args(Tuple<Args...> && t, const index_tuple<Indexes...>&)
  262. { (void)t; return T(::boost::forward<Args>(get<Indexes>(t))...); }
  263. public:
  264. template< template<class ...> class Tuple, class... Args1, class... Args2
  265. , class = typename pair_impl::disable_if_boost_tuple< Tuple<Args1...> >::type>
  266. pair(piecewise_construct_t, Tuple<Args1...> t1, Tuple<Args2...> t2)
  267. : first (build_from_args<first_type> (::boost::move(t1)))
  268. , second (build_from_args<second_type>(::boost::move(t2)))
  269. {
  270. BOOST_STATIC_ASSERT((sizeof(std::pair<T1, T2>) == sizeof(pair<T1, T2>)));
  271. }
  272. # endif //BOOST_NO_CXX11_VARIADIC_TEMPLATES
  273. #elif defined(BOOST_MSVC) && (_CPPLIB_VER == 520)
  274. //MSVC 2010 tuple implementation
  275. #define BOOST_PAIR_PIECEWISE_CONSTRUCT_MSVC2010_TUPLE_CODE(N,M)\
  276. template< template<class, class, class, class, class, class, class, class, class, class> class StdTuple \
  277. BOOST_MOVE_I_IF(BOOST_MOVE_OR(N,M)) BOOST_MOVE_CLASS##N BOOST_MOVE_I_IF(BOOST_MOVE_AND(N,M)) BOOST_MOVE_CLASSQ##M > \
  278. pair( piecewise_construct_t\
  279. , StdTuple<BOOST_MOVE_TARG##N BOOST_MOVE_I##N BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,N),::std::tr1::_Nil)> p\
  280. , StdTuple<BOOST_MOVE_TARGQ##M BOOST_MOVE_I##M BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,M),::std::tr1::_Nil)> q)\
  281. : first(BOOST_MOVE_GET_IDX##N), second(BOOST_MOVE_GET_IDXQ##M)\
  282. { (void)p; (void)q;\
  283. BOOST_STATIC_ASSERT((sizeof(std::pair<T1, T2>) == sizeof(pair<T1, T2>)));\
  284. }\
  285. //
  286. BOOST_MOVE_ITER2D_0TOMAX(9, BOOST_PAIR_PIECEWISE_CONSTRUCT_MSVC2010_TUPLE_CODE)
  287. #undef BOOST_PAIR_PIECEWISE_CONSTRUCT_MSVC2010_TUPLE_CODE
  288. #elif defined(BOOST_MSVC) && (_CPPLIB_VER == 540)
  289. #if _VARIADIC_MAX >= 9
  290. #define BOOST_PAIR_PIECEWISE_CONSTRUCT_MSVC2012_TUPLE_MAX_IT 9
  291. #else
  292. #define BOOST_PAIR_PIECEWISE_CONSTRUCT_MSVC2012_TUPLE_MAX_IT BOOST_MOVE_ADD(_VARIADIC_MAX, 1)
  293. #endif
  294. //MSVC 2012 tuple implementation
  295. #define BOOST_PAIR_PIECEWISE_CONSTRUCT_MSVC2012_TUPLE_CODE(N,M)\
  296. template< template<BOOST_MOVE_REPEAT(_VARIADIC_MAX, class), class, class, class> class StdTuple \
  297. BOOST_MOVE_I_IF(BOOST_MOVE_OR(N,M)) BOOST_MOVE_CLASS##N BOOST_MOVE_I_IF(BOOST_MOVE_AND(N,M)) BOOST_MOVE_CLASSQ##M > \
  298. pair( piecewise_construct_t\
  299. , StdTuple<BOOST_MOVE_TARG##N BOOST_MOVE_I##N BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(BOOST_MOVE_ADD(_VARIADIC_MAX, 3),N),::std::_Nil) > p\
  300. , StdTuple<BOOST_MOVE_TARGQ##M BOOST_MOVE_I##M BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(BOOST_MOVE_ADD(_VARIADIC_MAX, 3),M),::std::_Nil) > q)\
  301. : first(BOOST_MOVE_GET_IDX##N), second(BOOST_MOVE_GET_IDXQ##M)\
  302. { (void)p; (void)q;\
  303. BOOST_STATIC_ASSERT((sizeof(std::pair<T1, T2>) == sizeof(pair<T1, T2>)));\
  304. }\
  305. //
  306. BOOST_MOVE_ITER2D_0TOMAX(BOOST_PAIR_PIECEWISE_CONSTRUCT_MSVC2012_TUPLE_MAX_IT, BOOST_PAIR_PIECEWISE_CONSTRUCT_MSVC2012_TUPLE_CODE)
  307. #undef BOOST_PAIR_PIECEWISE_CONSTRUCT_MSVC2010_TUPLE_CODE
  308. #undef BOOST_PAIR_PIECEWISE_CONSTRUCT_MSVC2012_TUPLE_MAX_IT
  309. #endif
  310. //pair copy assignment
  311. pair& operator=(BOOST_COPY_ASSIGN_REF(pair) p)
  312. {
  313. first = p.first;
  314. second = p.second;
  315. return *this;
  316. }
  317. //pair move assignment
  318. pair& operator=(BOOST_RV_REF(pair) p)
  319. {
  320. first = ::boost::move(BOOST_MOVE_TO_LV(p).first);
  321. second = ::boost::move(BOOST_MOVE_TO_LV(p).second);
  322. return *this;
  323. }
  324. template <class D, class S>
  325. typename ::boost::container::dtl::disable_if_or
  326. < pair &
  327. , ::boost::container::dtl::is_same<T1, D>
  328. , ::boost::container::dtl::is_same<T2, S>
  329. >::type
  330. operator=(const pair<D, S>&p)
  331. {
  332. first = p.first;
  333. second = p.second;
  334. return *this;
  335. }
  336. template <class D, class S>
  337. typename ::boost::container::dtl::disable_if_or
  338. < pair &
  339. , ::boost::container::dtl::is_same<T1, D>
  340. , ::boost::container::dtl::is_same<T2, S>
  341. >::type
  342. operator=(BOOST_RV_REF_BEG pair<D, S> BOOST_RV_REF_END p)
  343. {
  344. first = ::boost::move(BOOST_MOVE_TO_LV(p).first);
  345. second = ::boost::move(BOOST_MOVE_TO_LV(p).second);
  346. return *this;
  347. }
  348. //std::pair copy assignment
  349. pair& operator=(const std::pair<T1, T2> &p)
  350. {
  351. first = p.first;
  352. second = p.second;
  353. return *this;
  354. }
  355. template <class D, class S>
  356. pair& operator=(const std::pair<D, S> &p)
  357. {
  358. first = ::boost::move(p.first);
  359. second = ::boost::move(p.second);
  360. return *this;
  361. }
  362. //std::pair move assignment
  363. pair& operator=(BOOST_RV_REF_BEG std::pair<T1, T2> BOOST_RV_REF_END p)
  364. {
  365. first = ::boost::move(BOOST_MOVE_TO_LV(p).first);
  366. second = ::boost::move(BOOST_MOVE_TO_LV(p).second);
  367. return *this;
  368. }
  369. template <class D, class S>
  370. pair& operator=(BOOST_RV_REF_BEG std::pair<D, S> BOOST_RV_REF_END p)
  371. {
  372. first = ::boost::move(BOOST_MOVE_TO_LV(p).first);
  373. second = ::boost::move(BOOST_MOVE_TO_LV(p).second);
  374. return *this;
  375. }
  376. //swap
  377. void swap(pair& p)
  378. {
  379. ::boost::adl_move_swap(this->first, p.first);
  380. ::boost::adl_move_swap(this->second, p.second);
  381. }
  382. };
  383. template <class T1, class T2>
  384. inline bool operator==(const pair<T1,T2>& x, const pair<T1,T2>& y)
  385. { return static_cast<bool>(x.first == y.first && x.second == y.second); }
  386. template <class T1, class T2>
  387. inline bool operator< (const pair<T1,T2>& x, const pair<T1,T2>& y)
  388. { return static_cast<bool>(x.first < y.first ||
  389. (!(y.first < x.first) && x.second < y.second)); }
  390. template <class T1, class T2>
  391. inline bool operator!=(const pair<T1,T2>& x, const pair<T1,T2>& y)
  392. { return static_cast<bool>(!(x == y)); }
  393. template <class T1, class T2>
  394. inline bool operator> (const pair<T1,T2>& x, const pair<T1,T2>& y)
  395. { return y < x; }
  396. template <class T1, class T2>
  397. inline bool operator>=(const pair<T1,T2>& x, const pair<T1,T2>& y)
  398. { return static_cast<bool>(!(x < y)); }
  399. template <class T1, class T2>
  400. inline bool operator<=(const pair<T1,T2>& x, const pair<T1,T2>& y)
  401. { return static_cast<bool>(!(y < x)); }
  402. template <class T1, class T2>
  403. inline pair<T1, T2> make_pair(T1 x, T2 y)
  404. { return pair<T1, T2>(x, y); }
  405. template <class T1, class T2>
  406. inline void swap(pair<T1, T2>& x, pair<T1, T2>& y)
  407. { x.swap(y); }
  408. } //namespace dtl {
  409. } //namespace container {
  410. #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
  411. template<class T1, class T2>
  412. struct has_move_emulation_enabled< ::boost::container::dtl::pair<T1, T2> >
  413. {
  414. static const bool value = true;
  415. };
  416. #endif
  417. namespace move_detail{
  418. template<class T>
  419. struct is_class_or_union;
  420. template <class T1, class T2>
  421. struct is_class_or_union< ::boost::container::dtl::pair<T1, T2> >
  422. //This specialization is needed to avoid instantiation of pair in
  423. //is_class, and allow recursive maps.
  424. {
  425. static const bool value = true;
  426. };
  427. template <class T1, class T2>
  428. struct is_class_or_union< std::pair<T1, T2> >
  429. //This specialization is needed to avoid instantiation of pair in
  430. //is_class, and allow recursive maps.
  431. {
  432. static const bool value = true;
  433. };
  434. template<class T>
  435. struct is_union;
  436. template <class T1, class T2>
  437. struct is_union< ::boost::container::dtl::pair<T1, T2> >
  438. //This specialization is needed to avoid instantiation of pair in
  439. //is_class, and allow recursive maps.
  440. {
  441. static const bool value = false;
  442. };
  443. template <class T1, class T2>
  444. struct is_union< std::pair<T1, T2> >
  445. //This specialization is needed to avoid instantiation of pair in
  446. //is_class, and allow recursive maps.
  447. {
  448. static const bool value = false;
  449. };
  450. template<class T>
  451. struct is_class;
  452. template <class T1, class T2>
  453. struct is_class< ::boost::container::dtl::pair<T1, T2> >
  454. //This specialization is needed to avoid instantiation of pair in
  455. //is_class, and allow recursive maps.
  456. {
  457. static const bool value = true;
  458. };
  459. template <class T1, class T2>
  460. struct is_class< std::pair<T1, T2> >
  461. //This specialization is needed to avoid instantiation of pair in
  462. //is_class, and allow recursive maps.
  463. {
  464. static const bool value = true;
  465. };
  466. //Triviality of pair
  467. template<class T>
  468. struct is_trivially_copy_constructible;
  469. template<class A, class B>
  470. struct is_trivially_copy_assignable
  471. <boost::container::dtl::pair<A,B> >
  472. {
  473. static const bool value = false ;
  474. };
  475. template<class T>
  476. struct is_trivially_move_constructible;
  477. template<class A, class B>
  478. struct is_trivially_move_assignable
  479. <boost::container::dtl::pair<A,B> >
  480. {
  481. static const bool value = false;
  482. };
  483. template<class T>
  484. struct is_trivially_copy_assignable;
  485. template<class A, class B>
  486. struct is_trivially_copy_constructible<boost::container::dtl::pair<A,B> >
  487. {
  488. static const bool value = false;
  489. };
  490. template<class T>
  491. struct is_trivially_move_assignable;
  492. template<class A, class B>
  493. struct is_trivially_move_constructible<boost::container::dtl::pair<A,B> >
  494. {
  495. static const bool value = false;
  496. };
  497. template<class T>
  498. struct is_trivially_destructible;
  499. template<class A, class B>
  500. struct is_trivially_destructible<boost::container::dtl::pair<A,B> >
  501. {
  502. static const bool value = boost::move_detail::is_trivially_destructible<A>::value &&
  503. boost::move_detail::is_trivially_destructible<B>::value ;
  504. };
  505. } //namespace move_detail{
  506. } //namespace boost {
  507. #include <boost/container/detail/config_end.hpp>
  508. #endif //#ifndef BOOST_CONTAINER_DETAIL_PAIR_HPP