scoped_allocator_adaptor_test.cpp 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/container for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. #include <boost/container/detail/config_begin.hpp>
  11. #include <boost/container/scoped_allocator_fwd.hpp>
  12. // container/detail
  13. #include <boost/container/detail/mpl.hpp>
  14. // move
  15. #include <boost/move/utility_core.hpp>
  16. #include <boost/move/adl_move_swap.hpp>
  17. //boost
  18. #include <boost/tuple/tuple.hpp>
  19. // std
  20. #include <memory>
  21. #include <cstddef>
  22. #if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
  23. #include <tuple>
  24. #endif
  25. //test
  26. #include <boost/core/lightweight_test.hpp>
  27. #include "allocator_argument_tester.hpp"
  28. template<unsigned int Type>
  29. struct tagged_integer
  30. {};
  31. struct mark_on_destructor
  32. {
  33. mark_on_destructor()
  34. {
  35. destroyed = false;
  36. }
  37. ~mark_on_destructor()
  38. {
  39. destroyed = true;
  40. }
  41. static bool destroyed;
  42. };
  43. bool mark_on_destructor::destroyed = false;
  44. #include <boost/container/scoped_allocator.hpp>
  45. #include <boost/static_assert.hpp>
  46. #include <boost/container/vector.hpp>
  47. #include <boost/container/detail/pair.hpp>
  48. int main()
  49. {
  50. using namespace boost::container;
  51. typedef propagation_test_allocator<tagged_integer<0>, 0> OuterAlloc;
  52. typedef propagation_test_allocator<tagged_integer<0>, 10> Outer10IdAlloc;
  53. typedef propagation_test_allocator<tagged_integer<9>, 0> Rebound9OuterAlloc;
  54. typedef propagation_test_allocator<tagged_integer<1>, 1> InnerAlloc1;
  55. typedef propagation_test_allocator<tagged_integer<2>, 2> InnerAlloc2;
  56. typedef propagation_test_allocator<tagged_integer<1>, 11> Inner11IdAlloc1;
  57. typedef propagation_test_allocator<tagged_integer<0>, 0, false> OuterAllocFalseHasTrueTypes;
  58. typedef propagation_test_allocator<tagged_integer<0>, 0, true> OuterAllocTrueHasTrueTypes;
  59. typedef propagation_test_allocator<tagged_integer<1>, 1, false> InnerAlloc1FalseHasTrueTypes;
  60. typedef propagation_test_allocator<tagged_integer<1>, 1, true> InnerAlloc1TrueHasTrueTypes;
  61. typedef propagation_test_allocator<tagged_integer<2>, 2, false> InnerAlloc2FalseHasTrueTypes;
  62. typedef propagation_test_allocator<tagged_integer<2>, 2, true> InnerAlloc2TrueHasTrueTypes;
  63. //
  64. typedef scoped_allocator_adaptor< OuterAlloc > Scoped0Inner;
  65. typedef scoped_allocator_adaptor< OuterAlloc
  66. , InnerAlloc1 > Scoped1Inner;
  67. typedef scoped_allocator_adaptor< OuterAlloc
  68. , InnerAlloc1
  69. , InnerAlloc2 > Scoped2Inner;
  70. typedef scoped_allocator_adaptor
  71. < scoped_allocator_adaptor
  72. <Outer10IdAlloc>
  73. > ScopedScoped0Inner;
  74. typedef scoped_allocator_adaptor
  75. < scoped_allocator_adaptor
  76. <Outer10IdAlloc, Inner11IdAlloc1>
  77. , InnerAlloc1
  78. > ScopedScoped1Inner;
  79. typedef scoped_allocator_adaptor< Rebound9OuterAlloc > Rebound9Scoped0Inner;
  80. typedef scoped_allocator_adaptor< Rebound9OuterAlloc
  81. , InnerAlloc1 > Rebound9Scoped1Inner;
  82. typedef scoped_allocator_adaptor< Rebound9OuterAlloc
  83. , InnerAlloc1
  84. , InnerAlloc2 > Rebound9Scoped2Inner;
  85. //outer_allocator_type
  86. BOOST_STATIC_ASSERT(( dtl::is_same< OuterAlloc
  87. , Scoped0Inner::outer_allocator_type>::value ));
  88. BOOST_STATIC_ASSERT(( dtl::is_same< OuterAlloc
  89. , Scoped1Inner::outer_allocator_type>::value ));
  90. BOOST_STATIC_ASSERT(( dtl::is_same< OuterAlloc
  91. , Scoped2Inner::outer_allocator_type>::value ));
  92. //value_type
  93. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::value_type
  94. , Scoped0Inner::value_type>::value ));
  95. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::value_type
  96. , Scoped1Inner::value_type>::value ));
  97. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::value_type
  98. , Scoped2Inner::value_type>::value ));
  99. //size_type
  100. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::size_type
  101. , Scoped0Inner::size_type>::value ));
  102. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::size_type
  103. , Scoped1Inner::size_type>::value ));
  104. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::size_type
  105. , Scoped2Inner::size_type>::value ));
  106. //difference_type
  107. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::difference_type
  108. , Scoped0Inner::difference_type>::value ));
  109. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::difference_type
  110. , Scoped1Inner::difference_type>::value ));
  111. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::difference_type
  112. , Scoped2Inner::difference_type>::value ));
  113. //pointer
  114. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::pointer
  115. , Scoped0Inner::pointer>::value ));
  116. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::pointer
  117. , Scoped1Inner::pointer>::value ));
  118. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::pointer
  119. , Scoped2Inner::pointer>::value ));
  120. //const_pointer
  121. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::const_pointer
  122. , Scoped0Inner::const_pointer>::value ));
  123. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::const_pointer
  124. , Scoped1Inner::const_pointer>::value ));
  125. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::const_pointer
  126. , Scoped2Inner::const_pointer>::value ));
  127. //void_pointer
  128. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::void_pointer
  129. , Scoped0Inner::void_pointer>::value ));
  130. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::void_pointer
  131. , Scoped1Inner::void_pointer>::value ));
  132. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::void_pointer
  133. , Scoped2Inner::void_pointer>::value ));
  134. //const_void_pointer
  135. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::const_void_pointer
  136. , Scoped0Inner::const_void_pointer>::value ));
  137. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::const_void_pointer
  138. , Scoped1Inner::const_void_pointer>::value ));
  139. BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::const_void_pointer
  140. , Scoped2Inner::const_void_pointer>::value ));
  141. //rebind
  142. BOOST_STATIC_ASSERT(( dtl::is_same<Scoped0Inner::rebind< tagged_integer<9> >::other
  143. , Rebound9Scoped0Inner >::value ));
  144. BOOST_STATIC_ASSERT(( dtl::is_same<Scoped1Inner::rebind< tagged_integer<9> >::other
  145. , Rebound9Scoped1Inner >::value ));
  146. BOOST_STATIC_ASSERT(( dtl::is_same<Scoped2Inner::rebind< tagged_integer<9> >::other
  147. , Rebound9Scoped2Inner >::value ));
  148. //inner_allocator_type
  149. BOOST_STATIC_ASSERT(( dtl::is_same< Scoped0Inner
  150. , Scoped0Inner::inner_allocator_type>::value ));
  151. BOOST_STATIC_ASSERT(( dtl::is_same< scoped_allocator_adaptor<InnerAlloc1>
  152. , Scoped1Inner::inner_allocator_type>::value ));
  153. BOOST_STATIC_ASSERT(( dtl::is_same< scoped_allocator_adaptor<InnerAlloc1, InnerAlloc2>
  154. , Scoped2Inner::inner_allocator_type>::value ));
  155. {
  156. //Propagation test
  157. typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes > Scoped0InnerF;
  158. typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes > Scoped0InnerT;
  159. typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes
  160. , InnerAlloc1FalseHasTrueTypes > Scoped1InnerFF;
  161. typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes
  162. , InnerAlloc1TrueHasTrueTypes > Scoped1InnerFT;
  163. typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes
  164. , InnerAlloc1FalseHasTrueTypes > Scoped1InnerTF;
  165. typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes
  166. , InnerAlloc1TrueHasTrueTypes > Scoped1InnerTT;
  167. typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes
  168. , InnerAlloc1FalseHasTrueTypes
  169. , InnerAlloc2FalseHasTrueTypes > Scoped2InnerFFF;
  170. typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes
  171. , InnerAlloc1FalseHasTrueTypes
  172. , InnerAlloc2TrueHasTrueTypes > Scoped2InnerFFT;
  173. typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes
  174. , InnerAlloc1TrueHasTrueTypes
  175. , InnerAlloc2FalseHasTrueTypes > Scoped2InnerFTF;
  176. typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes
  177. , InnerAlloc1TrueHasTrueTypes
  178. , InnerAlloc2TrueHasTrueTypes > Scoped2InnerFTT;
  179. typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes
  180. , InnerAlloc1FalseHasTrueTypes
  181. , InnerAlloc2FalseHasTrueTypes > Scoped2InnerTFF;
  182. typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes
  183. , InnerAlloc1FalseHasTrueTypes
  184. , InnerAlloc2TrueHasTrueTypes > Scoped2InnerTFT;
  185. typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes
  186. , InnerAlloc1TrueHasTrueTypes
  187. , InnerAlloc2FalseHasTrueTypes > Scoped2InnerTTF;
  188. typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes
  189. , InnerAlloc1TrueHasTrueTypes
  190. , InnerAlloc2TrueHasTrueTypes > Scoped2InnerTTT;
  191. //propagate_on_container_copy_assignment
  192. //0 inner
  193. BOOST_STATIC_ASSERT(( !Scoped0InnerF::propagate_on_container_copy_assignment::value ));
  194. BOOST_STATIC_ASSERT(( Scoped0InnerT::propagate_on_container_copy_assignment::value ));
  195. //1 inner
  196. BOOST_STATIC_ASSERT(( !Scoped1InnerFF::propagate_on_container_copy_assignment::value ));
  197. BOOST_STATIC_ASSERT(( Scoped1InnerFT::propagate_on_container_copy_assignment::value ));
  198. BOOST_STATIC_ASSERT(( Scoped1InnerTF::propagate_on_container_copy_assignment::value ));
  199. BOOST_STATIC_ASSERT(( Scoped1InnerTT::propagate_on_container_copy_assignment::value ));
  200. //2 inner
  201. BOOST_STATIC_ASSERT(( !Scoped2InnerFFF::propagate_on_container_copy_assignment::value ));
  202. BOOST_STATIC_ASSERT(( Scoped2InnerFFT::propagate_on_container_copy_assignment::value ));
  203. BOOST_STATIC_ASSERT(( Scoped2InnerFTF::propagate_on_container_copy_assignment::value ));
  204. BOOST_STATIC_ASSERT(( Scoped2InnerFTT::propagate_on_container_copy_assignment::value ));
  205. BOOST_STATIC_ASSERT(( Scoped2InnerTFF::propagate_on_container_copy_assignment::value ));
  206. BOOST_STATIC_ASSERT(( Scoped2InnerTFT::propagate_on_container_copy_assignment::value ));
  207. BOOST_STATIC_ASSERT(( Scoped2InnerTTF::propagate_on_container_copy_assignment::value ));
  208. BOOST_STATIC_ASSERT(( Scoped2InnerTTT::propagate_on_container_copy_assignment::value ));
  209. //propagate_on_container_move_assignment
  210. //0 inner
  211. BOOST_STATIC_ASSERT(( !Scoped0InnerF::propagate_on_container_move_assignment::value ));
  212. BOOST_STATIC_ASSERT(( Scoped0InnerT::propagate_on_container_move_assignment::value ));
  213. //1 inner
  214. BOOST_STATIC_ASSERT(( !Scoped1InnerFF::propagate_on_container_move_assignment::value ));
  215. BOOST_STATIC_ASSERT(( Scoped1InnerFT::propagate_on_container_move_assignment::value ));
  216. BOOST_STATIC_ASSERT(( Scoped1InnerTF::propagate_on_container_move_assignment::value ));
  217. BOOST_STATIC_ASSERT(( Scoped1InnerTT::propagate_on_container_move_assignment::value ));
  218. //2 inner
  219. BOOST_STATIC_ASSERT(( !Scoped2InnerFFF::propagate_on_container_move_assignment::value ));
  220. BOOST_STATIC_ASSERT(( Scoped2InnerFFT::propagate_on_container_move_assignment::value ));
  221. BOOST_STATIC_ASSERT(( Scoped2InnerFTF::propagate_on_container_move_assignment::value ));
  222. BOOST_STATIC_ASSERT(( Scoped2InnerFTT::propagate_on_container_move_assignment::value ));
  223. BOOST_STATIC_ASSERT(( Scoped2InnerTFF::propagate_on_container_move_assignment::value ));
  224. BOOST_STATIC_ASSERT(( Scoped2InnerTFT::propagate_on_container_move_assignment::value ));
  225. BOOST_STATIC_ASSERT(( Scoped2InnerTTF::propagate_on_container_move_assignment::value ));
  226. BOOST_STATIC_ASSERT(( Scoped2InnerTTT::propagate_on_container_move_assignment::value ));
  227. //propagate_on_container_swap
  228. //0 inner
  229. BOOST_STATIC_ASSERT(( !Scoped0InnerF::propagate_on_container_swap::value ));
  230. BOOST_STATIC_ASSERT(( Scoped0InnerT::propagate_on_container_swap::value ));
  231. //1 inner
  232. BOOST_STATIC_ASSERT(( !Scoped1InnerFF::propagate_on_container_swap::value ));
  233. BOOST_STATIC_ASSERT(( Scoped1InnerFT::propagate_on_container_swap::value ));
  234. BOOST_STATIC_ASSERT(( Scoped1InnerTF::propagate_on_container_swap::value ));
  235. BOOST_STATIC_ASSERT(( Scoped1InnerTT::propagate_on_container_swap::value ));
  236. //2 inner
  237. BOOST_STATIC_ASSERT(( !Scoped2InnerFFF::propagate_on_container_swap::value ));
  238. BOOST_STATIC_ASSERT(( Scoped2InnerFFT::propagate_on_container_swap::value ));
  239. BOOST_STATIC_ASSERT(( Scoped2InnerFTF::propagate_on_container_swap::value ));
  240. BOOST_STATIC_ASSERT(( Scoped2InnerFTT::propagate_on_container_swap::value ));
  241. BOOST_STATIC_ASSERT(( Scoped2InnerTFF::propagate_on_container_swap::value ));
  242. BOOST_STATIC_ASSERT(( Scoped2InnerTFT::propagate_on_container_swap::value ));
  243. BOOST_STATIC_ASSERT(( Scoped2InnerTTF::propagate_on_container_swap::value ));
  244. BOOST_STATIC_ASSERT(( Scoped2InnerTTT::propagate_on_container_swap::value ));
  245. //is_always_equal
  246. //0 inner
  247. BOOST_STATIC_ASSERT(( !Scoped0InnerF::is_always_equal::value ));
  248. BOOST_STATIC_ASSERT(( Scoped0InnerT::is_always_equal::value ));
  249. //1 inner
  250. BOOST_STATIC_ASSERT(( !Scoped1InnerFF::is_always_equal::value ));
  251. BOOST_STATIC_ASSERT(( !Scoped1InnerFT::is_always_equal::value ));
  252. BOOST_STATIC_ASSERT(( !Scoped1InnerTF::is_always_equal::value ));
  253. BOOST_STATIC_ASSERT(( Scoped1InnerTT::is_always_equal::value ));
  254. //2 inner
  255. BOOST_STATIC_ASSERT(( !Scoped2InnerFFF::is_always_equal::value ));
  256. BOOST_STATIC_ASSERT(( !Scoped2InnerFFT::is_always_equal::value ));
  257. BOOST_STATIC_ASSERT(( !Scoped2InnerFTF::is_always_equal::value ));
  258. BOOST_STATIC_ASSERT(( !Scoped2InnerFTT::is_always_equal::value ));
  259. BOOST_STATIC_ASSERT(( !Scoped2InnerTFF::is_always_equal::value ));
  260. BOOST_STATIC_ASSERT(( !Scoped2InnerTFT::is_always_equal::value ));
  261. BOOST_STATIC_ASSERT(( !Scoped2InnerTTF::is_always_equal::value ));
  262. BOOST_STATIC_ASSERT(( Scoped2InnerTTT::is_always_equal::value ));
  263. }
  264. //Default constructor
  265. {
  266. Scoped0Inner s0i;
  267. Scoped1Inner s1i;
  268. //Swap
  269. {
  270. Scoped0Inner s0i2;
  271. Scoped1Inner s1i2;
  272. boost::adl_move_swap(s0i, s0i2);
  273. boost::adl_move_swap(s1i, s1i2);
  274. }
  275. }
  276. //Default constructor
  277. {
  278. Scoped0Inner s0i;
  279. Scoped1Inner s1i;
  280. }
  281. //Copy constructor/assignment
  282. {
  283. Scoped0Inner s0i;
  284. Scoped1Inner s1i;
  285. Scoped2Inner s2i;
  286. Scoped0Inner s0i_b(s0i);
  287. Scoped1Inner s1i_b(s1i);
  288. Scoped2Inner s2i_b(s2i);
  289. BOOST_TEST(s0i == s0i_b);
  290. BOOST_TEST(s1i == s1i_b);
  291. BOOST_TEST(s2i == s2i_b);
  292. s0i_b = s0i;
  293. s1i_b = s1i;
  294. s2i_b = s2i;
  295. BOOST_TEST(s0i == s0i_b);
  296. BOOST_TEST(s1i == s1i_b);
  297. BOOST_TEST(s2i == s2i_b);
  298. }
  299. //Copy/move constructor/assignment
  300. {
  301. Scoped0Inner s0i;
  302. Scoped1Inner s1i;
  303. Scoped2Inner s2i;
  304. Scoped0Inner s0i_b(::boost::move(s0i));
  305. Scoped1Inner s1i_b(::boost::move(s1i));
  306. Scoped2Inner s2i_b(::boost::move(s2i));
  307. BOOST_TEST(s0i_b.outer_allocator().m_move_contructed);
  308. BOOST_TEST(s1i_b.outer_allocator().m_move_contructed);
  309. BOOST_TEST(s2i_b.outer_allocator().m_move_contructed);
  310. s0i_b = ::boost::move(s0i);
  311. s1i_b = ::boost::move(s1i);
  312. s2i_b = ::boost::move(s2i);
  313. BOOST_TEST(s0i_b.outer_allocator().m_move_assigned);
  314. BOOST_TEST(s1i_b.outer_allocator().m_move_assigned);
  315. BOOST_TEST(s2i_b.outer_allocator().m_move_assigned);
  316. }
  317. //inner_allocator()
  318. {
  319. Scoped0Inner s0i;
  320. Scoped1Inner s1i;
  321. Scoped2Inner s2i;
  322. const Scoped0Inner const_s0i;
  323. const Scoped1Inner const_s1i;
  324. const Scoped2Inner const_s2i;
  325. Scoped0Inner::inner_allocator_type &s0i_inner = s0i.inner_allocator();
  326. (void)s0i_inner;
  327. const Scoped0Inner::inner_allocator_type &const_s0i_inner = const_s0i.inner_allocator();
  328. (void)const_s0i_inner;
  329. Scoped1Inner::inner_allocator_type &s1i_inner = s1i.inner_allocator();
  330. (void)s1i_inner;
  331. const Scoped1Inner::inner_allocator_type &const_s1i_inner = const_s1i.inner_allocator();
  332. (void)const_s1i_inner;
  333. Scoped2Inner::inner_allocator_type &s2i_inner = s2i.inner_allocator();
  334. (void)s2i_inner;
  335. const Scoped2Inner::inner_allocator_type &const_s2i_inner = const_s2i.inner_allocator();
  336. (void)const_s2i_inner;
  337. }
  338. //operator==/!=
  339. {
  340. const Scoped0Inner const_s0i;
  341. const Rebound9Scoped0Inner const_rs0i;
  342. BOOST_TEST(const_s0i == const_s0i);
  343. BOOST_TEST(const_rs0i == const_s0i);
  344. BOOST_TEST(const_s0i == const_s0i);
  345. BOOST_TEST(const_s0i == const_rs0i);
  346. const Scoped1Inner const_s1i;
  347. const Rebound9Scoped1Inner const_rs1i;
  348. BOOST_TEST(const_s1i == const_s1i);
  349. BOOST_TEST(const_rs1i == const_s1i);
  350. BOOST_TEST(const_s1i == const_s1i);
  351. BOOST_TEST(const_s1i == const_rs1i);
  352. const Scoped2Inner const_s2i;
  353. const Rebound9Scoped2Inner const_rs2i;
  354. BOOST_TEST(const_s2i == const_s2i);
  355. BOOST_TEST(const_s2i == const_rs2i);
  356. BOOST_TEST(const_s2i == const_s2i);
  357. BOOST_TEST(const_s2i == const_rs2i);
  358. }
  359. //outer_allocator()
  360. {
  361. Scoped0Inner s0i;
  362. Scoped1Inner s1i;
  363. Scoped2Inner s2i;
  364. const Scoped0Inner const_s0i;
  365. const Scoped1Inner const_s1i;
  366. const Scoped2Inner const_s2i;
  367. Scoped0Inner::outer_allocator_type &s0i_inner = s0i.outer_allocator();
  368. (void)s0i_inner;
  369. const Scoped0Inner::outer_allocator_type &const_s0i_inner = const_s0i.outer_allocator();
  370. (void)const_s0i_inner;
  371. Scoped1Inner::outer_allocator_type &s1i_inner = s1i.outer_allocator();
  372. (void)s1i_inner;
  373. const Scoped1Inner::outer_allocator_type &const_s1i_inner = const_s1i.outer_allocator();
  374. (void)const_s1i_inner;
  375. Scoped2Inner::outer_allocator_type &s2i_inner = s2i.outer_allocator();
  376. (void)s2i_inner;
  377. const Scoped2Inner::outer_allocator_type &const_s2i_inner = const_s2i.outer_allocator();
  378. (void)const_s2i_inner;
  379. }
  380. //max_size()
  381. {
  382. const Scoped0Inner const_s0i;
  383. const Scoped1Inner const_s1i;
  384. const Scoped2Inner const_s2i;
  385. const OuterAlloc const_oa;
  386. const InnerAlloc1 const_ia1;
  387. const InnerAlloc2 const_ia2;
  388. BOOST_TEST(const_s0i.max_size() == const_oa.max_size());
  389. BOOST_TEST(const_s1i.max_size() == const_oa.max_size());
  390. BOOST_TEST(const_s2i.max_size() == const_oa.max_size());
  391. BOOST_TEST(const_s1i.inner_allocator().max_size() == const_ia1.max_size());
  392. BOOST_TEST(const_s2i.inner_allocator().inner_allocator().max_size() == const_ia2.max_size());
  393. }
  394. //Copy and move operations
  395. {
  396. //Construction
  397. {
  398. Scoped0Inner s0i_a, s0i_b(s0i_a), s0i_c(::boost::move(s0i_b));
  399. Scoped1Inner s1i_a, s1i_b(s1i_a), s1i_c(::boost::move(s1i_b));
  400. Scoped2Inner s2i_a, s2i_b(s2i_a), s2i_c(::boost::move(s2i_b));
  401. }
  402. //Assignment
  403. {
  404. Scoped0Inner s0i_a, s0i_b;
  405. s0i_a = s0i_b;
  406. s0i_a = ::boost::move(s0i_b);
  407. Scoped1Inner s1i_a, s1i_b;
  408. s1i_a = s1i_b;
  409. s1i_a = ::boost::move(s1i_b);
  410. Scoped2Inner s2i_a, s2i_b;
  411. s2i_a = s2i_b;
  412. s2i_a = ::boost::move(s2i_b);
  413. }
  414. OuterAlloc oa;
  415. InnerAlloc1 ia1;
  416. InnerAlloc2 ia2;
  417. Rebound9OuterAlloc roa;
  418. Rebound9Scoped0Inner rs0i;
  419. Rebound9Scoped1Inner rs1i;
  420. Rebound9Scoped2Inner rs2i;
  421. //Copy from outer
  422. {
  423. Scoped0Inner s0i(oa);
  424. Scoped1Inner s1i(oa, ia1);
  425. Scoped2Inner s2i(oa, ia1, ia2);
  426. }
  427. //Move from outer
  428. {
  429. Scoped0Inner s0i(::boost::move(oa));
  430. Scoped1Inner s1i(::boost::move(oa), ia1);
  431. Scoped2Inner s2i(::boost::move(oa), ia1, ia2);
  432. }
  433. //Copy from rebound outer
  434. {
  435. Scoped0Inner s0i(roa);
  436. Scoped1Inner s1i(roa, ia1);
  437. Scoped2Inner s2i(roa, ia1, ia2);
  438. }
  439. //Move from rebound outer
  440. {
  441. Scoped0Inner s0i(::boost::move(roa));
  442. Scoped1Inner s1i(::boost::move(roa), ia1);
  443. Scoped2Inner s2i(::boost::move(roa), ia1, ia2);
  444. }
  445. //Copy from rebound scoped
  446. {
  447. Scoped0Inner s0i(rs0i);
  448. Scoped1Inner s1i(rs1i);
  449. Scoped2Inner s2i(rs2i);
  450. }
  451. //Move from rebound scoped
  452. {
  453. Scoped0Inner s0i(::boost::move(rs0i));
  454. Scoped1Inner s1i(::boost::move(rs1i));
  455. Scoped2Inner s2i(::boost::move(rs2i));
  456. }
  457. }
  458. {
  459. vector<int, scoped_allocator_adaptor< propagation_test_allocator<int, 0> > > dummy;
  460. dummy.push_back(0);
  461. }
  462. //destroy()
  463. {
  464. {
  465. Scoped0Inner s0i;
  466. mark_on_destructor mod;
  467. s0i.destroy(&mod);
  468. BOOST_TEST(mark_on_destructor::destroyed);
  469. }
  470. {
  471. Scoped1Inner s1i;
  472. mark_on_destructor mod;
  473. s1i.destroy(&mod);
  474. BOOST_TEST(mark_on_destructor::destroyed);
  475. }
  476. {
  477. Scoped2Inner s2i;
  478. mark_on_destructor mod;
  479. s2i.destroy(&mod);
  480. BOOST_TEST(mark_on_destructor::destroyed);
  481. }
  482. }
  483. //construct
  484. {
  485. ////////////////////////////////////////////////////////////
  486. //First check scoped allocator with just OuterAlloc.
  487. //In this case OuterAlloc (propagation_test_allocator with tag 0) should be
  488. //used to construct types.
  489. ////////////////////////////////////////////////////////////
  490. {
  491. Scoped0Inner s0i;
  492. //Check construction with 0 user arguments
  493. {
  494. typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
  495. MarkType dummy;
  496. dummy.~MarkType();
  497. s0i.construct(&dummy);
  498. BOOST_TEST(dummy.construction_type == NotUsesAllocator);
  499. BOOST_TEST(dummy.value == 0 );
  500. dummy.~MarkType();
  501. }
  502. {
  503. typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
  504. MarkType dummy;
  505. dummy.~MarkType();
  506. s0i.construct(&dummy);
  507. BOOST_TEST(dummy.construction_type == ConstructibleSuffix);
  508. BOOST_TEST(dummy.value == 0);
  509. dummy.~MarkType();
  510. }
  511. {
  512. typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
  513. MarkType dummy;
  514. dummy.~MarkType();
  515. s0i.construct(&dummy);
  516. BOOST_TEST(dummy.construction_type == ConstructiblePrefix);
  517. BOOST_TEST(dummy.value == 0);
  518. dummy.~MarkType();
  519. }
  520. //Check construction with 1 user arguments
  521. {
  522. typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
  523. MarkType dummy;
  524. dummy.~MarkType();
  525. s0i.construct(&dummy, 1);
  526. BOOST_TEST(dummy.construction_type == NotUsesAllocator);
  527. BOOST_TEST(dummy.value == 1);
  528. dummy.~MarkType();
  529. }
  530. {
  531. typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
  532. MarkType dummy;
  533. dummy.~MarkType();
  534. s0i.construct(&dummy, 2);
  535. BOOST_TEST(dummy.construction_type == ConstructibleSuffix);
  536. BOOST_TEST(dummy.value == 2);
  537. dummy.~MarkType();
  538. }
  539. {
  540. typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
  541. MarkType dummy;
  542. dummy.~MarkType();
  543. s0i.construct(&dummy, 3);
  544. BOOST_TEST(dummy.construction_type == ConstructiblePrefix);
  545. BOOST_TEST(dummy.value == 3);
  546. dummy.~MarkType();
  547. }
  548. }
  549. ////////////////////////////////////////////////////////////
  550. //Then check scoped allocator with OuterAlloc and InnerAlloc.
  551. //In this case InnerAlloc (propagation_test_allocator with tag 1) should be
  552. //used to construct types.
  553. ////////////////////////////////////////////////////////////
  554. {
  555. Scoped1Inner s1i;
  556. //Check construction with 0 user arguments
  557. {
  558. typedef ::allocator_argument_tester<NotUsesAllocator, 1> MarkType;
  559. MarkType dummy;
  560. dummy.~MarkType();
  561. s1i.construct(&dummy);
  562. BOOST_TEST(dummy.construction_type == NotUsesAllocator);
  563. BOOST_TEST(dummy.value == 0);
  564. dummy.~MarkType();
  565. }
  566. {
  567. typedef ::allocator_argument_tester<ConstructibleSuffix, 1> MarkType;
  568. MarkType dummy;
  569. dummy.~MarkType();
  570. s1i.construct(&dummy);
  571. BOOST_TEST(dummy.construction_type == ConstructibleSuffix);
  572. BOOST_TEST(dummy.value == 0);
  573. dummy.~MarkType();
  574. }
  575. {
  576. typedef ::allocator_argument_tester<ConstructiblePrefix, 1> MarkType;
  577. MarkType dummy;
  578. dummy.~MarkType();
  579. s1i.construct(&dummy);
  580. BOOST_TEST(dummy.construction_type == ConstructiblePrefix);
  581. BOOST_TEST(dummy.value == 0);
  582. dummy.~MarkType();
  583. }
  584. //Check construction with 1 user arguments
  585. {
  586. typedef ::allocator_argument_tester<NotUsesAllocator, 1> MarkType;
  587. MarkType dummy;
  588. dummy.~MarkType();
  589. s1i.construct(&dummy, 1);
  590. BOOST_TEST(dummy.construction_type == NotUsesAllocator);
  591. BOOST_TEST(dummy.value == 1);
  592. dummy.~MarkType();
  593. }
  594. {
  595. typedef ::allocator_argument_tester<ConstructibleSuffix, 1> MarkType;
  596. MarkType dummy;
  597. dummy.~MarkType();
  598. s1i.construct(&dummy, 2);
  599. BOOST_TEST(dummy.construction_type == ConstructibleSuffix);
  600. BOOST_TEST(dummy.value == 2);
  601. dummy.~MarkType();
  602. }
  603. {
  604. typedef ::allocator_argument_tester<ConstructiblePrefix, 1> MarkType;
  605. MarkType dummy;
  606. dummy.~MarkType();
  607. s1i.construct(&dummy, 3);
  608. BOOST_TEST(dummy.construction_type == ConstructiblePrefix);
  609. BOOST_TEST(dummy.value == 3);
  610. dummy.~MarkType();
  611. }
  612. }
  613. //////////////////////////////////////////////////////////////////////////////////
  614. //Now test recursive OuterAllocator types (OuterAllocator is a scoped_allocator)
  615. //////////////////////////////////////////////////////////////////////////////////
  616. ////////////////////////////////////////////////////////////
  617. //First check scoped allocator with just OuterAlloc.
  618. //In this case OuterAlloc (propagation_test_allocator with tag 0) should be
  619. //used to construct types.
  620. ////////////////////////////////////////////////////////////
  621. {
  622. //Check outer_allocator_type is scoped
  623. BOOST_STATIC_ASSERT(( is_scoped_allocator
  624. <ScopedScoped0Inner::outer_allocator_type>::value ));
  625. BOOST_STATIC_ASSERT(( dtl::is_same
  626. < outermost_allocator<ScopedScoped0Inner>::type
  627. , Outer10IdAlloc
  628. >::value ));
  629. BOOST_STATIC_ASSERT(( dtl::is_same
  630. < ScopedScoped0Inner::outer_allocator_type
  631. , scoped_allocator_adaptor<Outer10IdAlloc>
  632. >::value ));
  633. BOOST_STATIC_ASSERT(( dtl::is_same
  634. < scoped_allocator_adaptor<Outer10IdAlloc>::outer_allocator_type
  635. , Outer10IdAlloc
  636. >::value ));
  637. ScopedScoped0Inner ssro0i;
  638. Outer10IdAlloc & val = outermost_allocator<ScopedScoped0Inner>::get(ssro0i);
  639. (void)val;
  640. //Check construction with 0 user arguments
  641. {
  642. typedef ::allocator_argument_tester<NotUsesAllocator, 10> MarkType;
  643. MarkType dummy;
  644. dummy.~MarkType();
  645. ssro0i.construct(&dummy);
  646. BOOST_TEST(dummy.construction_type == NotUsesAllocator);
  647. BOOST_TEST(dummy.value == 0);
  648. dummy.~MarkType();
  649. }
  650. {
  651. typedef ::allocator_argument_tester<ConstructibleSuffix, 10> MarkType;
  652. MarkType dummy;
  653. dummy.~MarkType();
  654. ssro0i.construct(&dummy);
  655. BOOST_TEST(dummy.construction_type == ConstructibleSuffix);
  656. BOOST_TEST(dummy.value == 0);
  657. dummy.~MarkType();
  658. }
  659. {
  660. typedef ::allocator_argument_tester<ConstructiblePrefix, 10> MarkType;
  661. MarkType dummy;
  662. dummy.~MarkType();
  663. ssro0i.construct(&dummy);
  664. BOOST_TEST(dummy.construction_type == ConstructiblePrefix);
  665. BOOST_TEST(dummy.value == 0);
  666. dummy.~MarkType();
  667. }
  668. //Check construction with 1 user arguments
  669. {
  670. typedef ::allocator_argument_tester<NotUsesAllocator, 10> MarkType;
  671. MarkType dummy;
  672. dummy.~MarkType();
  673. ssro0i.construct(&dummy, 1);
  674. BOOST_TEST(dummy.construction_type == NotUsesAllocator);
  675. BOOST_TEST(dummy.value == 1);
  676. dummy.~MarkType();
  677. }
  678. {
  679. typedef ::allocator_argument_tester<ConstructibleSuffix, 10> MarkType;
  680. MarkType dummy;
  681. dummy.~MarkType();
  682. ssro0i.construct(&dummy, 2);
  683. BOOST_TEST(dummy.construction_type == ConstructibleSuffix);
  684. BOOST_TEST(dummy.value == 2);
  685. dummy.~MarkType();
  686. }
  687. {
  688. typedef ::allocator_argument_tester<ConstructiblePrefix, 10> MarkType;
  689. MarkType dummy;
  690. dummy.~MarkType();
  691. ssro0i.construct(&dummy, 3);
  692. BOOST_TEST(dummy.construction_type == ConstructiblePrefix);
  693. BOOST_TEST(dummy.value == 3);
  694. dummy.~MarkType();
  695. }
  696. }
  697. ////////////////////////////////////////////////////////////
  698. //Then check scoped allocator with OuterAlloc and InnerAlloc.
  699. //In this case inner_allocator_type is not convertible to
  700. //::allocator_argument_tester<XXX, 10> so uses_allocator
  701. //should be false on all tests.
  702. ////////////////////////////////////////////////////////////
  703. {
  704. //Check outer_allocator_type is scoped
  705. BOOST_STATIC_ASSERT(( is_scoped_allocator
  706. <ScopedScoped1Inner::outer_allocator_type>::value ));
  707. BOOST_STATIC_ASSERT(( dtl::is_same
  708. < outermost_allocator<ScopedScoped1Inner>::type
  709. , Outer10IdAlloc
  710. >::value ));
  711. BOOST_STATIC_ASSERT(( dtl::is_same
  712. < ScopedScoped1Inner::outer_allocator_type
  713. , scoped_allocator_adaptor<Outer10IdAlloc, Inner11IdAlloc1>
  714. >::value ));
  715. BOOST_STATIC_ASSERT(( dtl::is_same
  716. < scoped_allocator_adaptor<Outer10IdAlloc, Inner11IdAlloc1>::outer_allocator_type
  717. , Outer10IdAlloc
  718. >::value ));
  719. BOOST_STATIC_ASSERT(( !
  720. uses_allocator
  721. < ::allocator_argument_tester<ConstructibleSuffix, 10>
  722. , ScopedScoped1Inner::inner_allocator_type::outer_allocator_type
  723. >::value ));
  724. ScopedScoped1Inner ssro1i;
  725. Outer10IdAlloc & val = outermost_allocator<ScopedScoped1Inner>::get(ssro1i);
  726. (void)val;
  727. //Check construction with 0 user arguments
  728. {
  729. typedef ::allocator_argument_tester<NotUsesAllocator, 10> MarkType;
  730. MarkType dummy;
  731. dummy.~MarkType();
  732. ssro1i.construct(&dummy);
  733. BOOST_TEST(dummy.construction_type == NotUsesAllocator);
  734. BOOST_TEST(dummy.value == 0);
  735. dummy.~MarkType();
  736. }
  737. {
  738. typedef ::allocator_argument_tester<ConstructibleSuffix, 10> MarkType;
  739. MarkType dummy;
  740. dummy.~MarkType();
  741. ssro1i.construct(&dummy);
  742. BOOST_TEST(dummy.construction_type == NotUsesAllocator);
  743. BOOST_TEST(dummy.value == 0);
  744. dummy.~MarkType();
  745. }
  746. {
  747. typedef ::allocator_argument_tester<ConstructiblePrefix, 10> MarkType;
  748. MarkType dummy;
  749. dummy.~MarkType();
  750. ssro1i.construct(&dummy);
  751. BOOST_TEST(dummy.construction_type == NotUsesAllocator);
  752. BOOST_TEST(dummy.value == 0);
  753. dummy.~MarkType();
  754. }
  755. //Check construction with 1 user arguments
  756. {
  757. typedef ::allocator_argument_tester<NotUsesAllocator, 10> MarkType;
  758. MarkType dummy;
  759. dummy.~MarkType();
  760. ssro1i.construct(&dummy, 1);
  761. BOOST_TEST(dummy.construction_type == NotUsesAllocator);
  762. BOOST_TEST(dummy.value == 1);
  763. dummy.~MarkType();
  764. }
  765. {
  766. typedef ::allocator_argument_tester<ConstructibleSuffix, 10> MarkType;
  767. MarkType dummy;
  768. dummy.~MarkType();
  769. ssro1i.construct(&dummy, 2);
  770. BOOST_TEST(dummy.construction_type == NotUsesAllocator);
  771. BOOST_TEST(dummy.value == 2);
  772. dummy.~MarkType();
  773. }
  774. {
  775. typedef ::allocator_argument_tester<ConstructiblePrefix, 10> MarkType;
  776. MarkType dummy;
  777. dummy.~MarkType();
  778. ssro1i.construct(&dummy, 3);
  779. BOOST_TEST(dummy.construction_type == NotUsesAllocator);
  780. BOOST_TEST(dummy.value == 3);
  781. dummy.~MarkType();
  782. }
  783. }
  784. ////////////////////////////////////////////////////////////
  785. //Now check propagation to pair
  786. ////////////////////////////////////////////////////////////
  787. //First check scoped allocator with just OuterAlloc.
  788. //In this case OuterAlloc (propagation_test_allocator with tag 0) should be
  789. //used to construct types.
  790. ////////////////////////////////////////////////////////////
  791. {
  792. using dtl::pair;
  793. typedef propagation_test_allocator< pair< tagged_integer<0>
  794. , tagged_integer<0> >, 0> OuterPairAlloc;
  795. //
  796. typedef scoped_allocator_adaptor < OuterPairAlloc > ScopedPair0Inner;
  797. ScopedPair0Inner s0i;
  798. //Check construction with 0 user arguments
  799. {
  800. typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
  801. typedef pair<MarkType, MarkType> MarkTypePair;
  802. MarkTypePair dummy;
  803. dummy.~MarkTypePair();
  804. s0i.construct(&dummy);
  805. BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
  806. BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
  807. BOOST_TEST(dummy.first.value == 0);
  808. BOOST_TEST(dummy.second.value == 0);
  809. dummy.~MarkTypePair();
  810. }
  811. {
  812. typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
  813. typedef pair<MarkType, MarkType> MarkTypePair;
  814. MarkTypePair dummy;
  815. dummy.~MarkTypePair();
  816. s0i.construct(&dummy);
  817. BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
  818. BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
  819. BOOST_TEST(dummy.first.value == 0);
  820. BOOST_TEST(dummy.second.value == 0);
  821. dummy.~MarkTypePair();
  822. }
  823. {
  824. typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
  825. typedef pair<MarkType, MarkType> MarkTypePair;
  826. MarkTypePair dummy;
  827. dummy.~MarkTypePair();
  828. s0i.construct(&dummy);
  829. BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
  830. BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
  831. BOOST_TEST(dummy.first.value == 0);
  832. BOOST_TEST(dummy.second.value == 0);
  833. dummy.~MarkTypePair();
  834. }
  835. #if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
  836. //Check construction with 0 user arguments and Std tuple
  837. {
  838. typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
  839. typedef pair<MarkType, MarkType> MarkTypePair;
  840. MarkTypePair dummy;
  841. dummy.~MarkTypePair();
  842. s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<>());
  843. BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
  844. BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
  845. BOOST_TEST(dummy.first.value == 0);
  846. BOOST_TEST(dummy.second.value == 0);
  847. dummy.~MarkTypePair();
  848. }
  849. {
  850. typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
  851. typedef pair<MarkType, MarkType> MarkTypePair;
  852. MarkTypePair dummy;
  853. dummy.~MarkTypePair();
  854. s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<>());
  855. BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
  856. BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
  857. BOOST_TEST(dummy.first.value == 0);
  858. BOOST_TEST(dummy.second.value == 0);
  859. dummy.~MarkTypePair();
  860. }
  861. {
  862. typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
  863. typedef pair<MarkType, MarkType> MarkTypePair;
  864. MarkTypePair dummy;
  865. dummy.~MarkTypePair();
  866. s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<>());
  867. BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
  868. BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
  869. BOOST_TEST(dummy.first.value == 0);
  870. BOOST_TEST(dummy.second.value == 0);
  871. dummy.~MarkTypePair();
  872. }
  873. {
  874. typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
  875. typedef pair<MarkType, MarkType> MarkTypePair;
  876. MarkTypePair dummy;
  877. dummy.~MarkTypePair();
  878. s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<>());
  879. BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
  880. BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
  881. BOOST_TEST(dummy.first.value == 0);
  882. BOOST_TEST(dummy.second.value == 0);
  883. dummy.~MarkTypePair();
  884. }
  885. {
  886. typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
  887. typedef pair<MarkType, MarkType> MarkTypePair;
  888. MarkTypePair dummy;
  889. dummy.~MarkTypePair();
  890. s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<>());
  891. BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
  892. BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
  893. BOOST_TEST(dummy.first.value == 0);
  894. BOOST_TEST(dummy.second.value == 0);
  895. dummy.~MarkTypePair();
  896. }
  897. {
  898. typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
  899. typedef pair<MarkType, MarkType> MarkTypePair;
  900. MarkTypePair dummy;
  901. dummy.~MarkTypePair();
  902. s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<>());
  903. BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
  904. BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
  905. BOOST_TEST(dummy.first.value == 0);
  906. BOOST_TEST(dummy.second.value == 0);
  907. dummy.~MarkTypePair();
  908. }
  909. #endif //BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE
  910. //Check construction with 1 user arguments for each pair
  911. {
  912. typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
  913. typedef pair<MarkType, MarkType> MarkTypePair;
  914. MarkTypePair dummy;
  915. dummy.~MarkTypePair();
  916. s0i.construct(&dummy, 1, 1);
  917. BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
  918. BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
  919. BOOST_TEST(dummy.first.value == 1);
  920. BOOST_TEST(dummy.second.value == 1);
  921. dummy.~MarkTypePair();
  922. }
  923. {
  924. typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
  925. typedef pair<MarkType, MarkType> MarkTypePair;
  926. MarkTypePair dummy;
  927. dummy.~MarkTypePair();
  928. s0i.construct(&dummy, 1, 1);
  929. BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
  930. BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
  931. BOOST_TEST(dummy.first.value == 1);
  932. BOOST_TEST(dummy.second.value == 1);
  933. dummy.~MarkTypePair();
  934. }
  935. {
  936. typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
  937. typedef pair<MarkType, MarkType> MarkTypePair;
  938. MarkTypePair dummy;
  939. dummy.~MarkTypePair();
  940. s0i.construct(&dummy, 2, 2);
  941. BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
  942. BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
  943. BOOST_TEST(dummy.first.value == 2);
  944. BOOST_TEST(dummy.second.value == 2);
  945. dummy.~MarkTypePair();
  946. }
  947. //Check construction with 1 user arguments for each pair and Boost tuple
  948. {
  949. typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
  950. typedef pair<MarkType, MarkType> MarkTypePair;
  951. MarkTypePair dummy;
  952. dummy.~MarkTypePair();
  953. s0i.construct(&dummy, piecewise_construct, boost::tuple<int>(1), boost::tuple<int>(1));
  954. BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
  955. BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
  956. BOOST_TEST(dummy.first.value == 1);
  957. BOOST_TEST(dummy.second.value == 1);
  958. dummy.~MarkTypePair();
  959. }
  960. {
  961. typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
  962. typedef pair<MarkType, MarkType> MarkTypePair;
  963. MarkTypePair dummy;
  964. dummy.~MarkTypePair();
  965. s0i.construct(&dummy, piecewise_construct, boost::tuple<int>(1), boost::tuple<int>(1));
  966. BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
  967. BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
  968. BOOST_TEST(dummy.first.value == 1);
  969. BOOST_TEST(dummy.second.value == 1);
  970. dummy.~MarkTypePair();
  971. }
  972. {
  973. typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
  974. typedef pair<MarkType, MarkType> MarkTypePair;
  975. MarkTypePair dummy;
  976. dummy.~MarkTypePair();
  977. s0i.construct(&dummy, piecewise_construct, boost::tuple<int>(2), boost::tuple<int>(2));
  978. BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
  979. BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
  980. BOOST_TEST(dummy.first.value == 2);
  981. BOOST_TEST(dummy.second.value == 2);
  982. dummy.~MarkTypePair();
  983. }
  984. #if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
  985. //Check construction with 1 user arguments for each pair and Boost tuple
  986. {
  987. typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
  988. typedef pair<MarkType, MarkType> MarkTypePair;
  989. MarkTypePair dummy;
  990. dummy.~MarkTypePair();
  991. s0i.construct(&dummy, piecewise_construct, std::tuple<int>(1), std::tuple<int>(1));
  992. BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
  993. BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
  994. BOOST_TEST(dummy.first.value == 1);
  995. BOOST_TEST(dummy.second.value == 1);
  996. dummy.~MarkTypePair();
  997. }
  998. {
  999. typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
  1000. typedef pair<MarkType, MarkType> MarkTypePair;
  1001. MarkTypePair dummy;
  1002. dummy.~MarkTypePair();
  1003. s0i.construct(&dummy, piecewise_construct, std::tuple<int>(1), std::tuple<int>(1));
  1004. BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
  1005. BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
  1006. BOOST_TEST(dummy.first.value == 1);
  1007. BOOST_TEST(dummy.second.value == 1);
  1008. dummy.~MarkTypePair();
  1009. }
  1010. {
  1011. typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
  1012. typedef pair<MarkType, MarkType> MarkTypePair;
  1013. MarkTypePair dummy;
  1014. dummy.~MarkTypePair();
  1015. s0i.construct(&dummy, piecewise_construct, std::tuple<int>(2), std::tuple<int>(2));
  1016. BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
  1017. BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
  1018. BOOST_TEST(dummy.first.value == 2);
  1019. BOOST_TEST(dummy.second.value == 2);
  1020. dummy.~MarkTypePair();
  1021. }
  1022. #endif //BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE
  1023. //Check construction with pair copy construction
  1024. {
  1025. typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
  1026. typedef pair<MarkType, MarkType> MarkTypePair;
  1027. MarkTypePair dummy, dummy2;
  1028. dummy.~MarkTypePair();
  1029. s0i.construct(&dummy, dummy2);
  1030. BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
  1031. BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
  1032. BOOST_TEST(dummy.first.value == 0);
  1033. BOOST_TEST(dummy.second.value == 0);
  1034. dummy.~MarkTypePair();
  1035. }
  1036. {
  1037. typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
  1038. typedef pair<MarkType, MarkType> MarkTypePair;
  1039. MarkTypePair dummy, dummy2(1, 1);
  1040. dummy.~MarkTypePair();
  1041. s0i.construct(&dummy, dummy2);
  1042. BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
  1043. BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
  1044. BOOST_TEST(dummy.first.value == 1);
  1045. BOOST_TEST(dummy.second.value == 1);
  1046. dummy.~MarkTypePair();
  1047. }
  1048. {
  1049. typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
  1050. typedef pair<MarkType, MarkType> MarkTypePair;
  1051. MarkTypePair dummy, dummy2(2, 2);
  1052. dummy.~MarkTypePair();
  1053. s0i.construct(&dummy, dummy2);
  1054. BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
  1055. BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
  1056. BOOST_TEST(dummy.first.value == 2);
  1057. BOOST_TEST(dummy.second.value == 2);
  1058. dummy.~MarkTypePair();
  1059. }
  1060. //Check construction with pair move construction
  1061. {
  1062. typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
  1063. typedef pair<MarkType, MarkType> MarkTypePair;
  1064. MarkTypePair dummy, dummy2(3, 3);
  1065. dummy2.first.construction_type = dummy2.second.construction_type = ConstructibleSuffix;
  1066. dummy.~MarkTypePair();
  1067. s0i.construct(&dummy, ::boost::move(dummy2));
  1068. BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
  1069. BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
  1070. BOOST_TEST(dummy.first.value == 3);
  1071. BOOST_TEST(dummy.second.value == 3);
  1072. BOOST_TEST(dummy2.first.construction_type == NotUsesAllocator);
  1073. BOOST_TEST(dummy2.second.construction_type == NotUsesAllocator);
  1074. BOOST_TEST(dummy2.first.value == 0);
  1075. BOOST_TEST(dummy2.second.value == 0);
  1076. dummy.~MarkTypePair();
  1077. }
  1078. {
  1079. typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
  1080. typedef pair<MarkType, MarkType> MarkTypePair;
  1081. MarkTypePair dummy, dummy2(1, 1);
  1082. dummy.~MarkTypePair();
  1083. s0i.construct(&dummy, ::boost::move(dummy2));
  1084. BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
  1085. BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
  1086. BOOST_TEST(dummy.first.value == 1);
  1087. BOOST_TEST(dummy.second.value == 1);
  1088. BOOST_TEST(dummy2.first.construction_type == ConstructibleSuffix);
  1089. BOOST_TEST(dummy2.second.construction_type == ConstructibleSuffix);
  1090. BOOST_TEST(dummy2.first.value == 0);
  1091. BOOST_TEST(dummy2.second.value == 0);
  1092. dummy.~MarkTypePair();
  1093. }
  1094. {
  1095. typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
  1096. typedef pair<MarkType, MarkType> MarkTypePair;
  1097. MarkTypePair dummy, dummy2(2, 2);
  1098. dummy.~MarkTypePair();
  1099. s0i.construct(&dummy, ::boost::move(dummy2));
  1100. BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
  1101. BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
  1102. BOOST_TEST(dummy.first.value == 2);
  1103. BOOST_TEST(dummy.second.value == 2);
  1104. BOOST_TEST(dummy2.first.construction_type == ConstructiblePrefix);
  1105. BOOST_TEST(dummy2.second.construction_type == ConstructiblePrefix);
  1106. BOOST_TEST(dummy2.first.value == 0);
  1107. BOOST_TEST(dummy2.second.value == 0);
  1108. dummy.~MarkTypePair();
  1109. }
  1110. //Check construction with related pair copy construction
  1111. {
  1112. typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
  1113. typedef pair<MarkType, MarkType> MarkTypePair;
  1114. MarkTypePair dummy;
  1115. pair<int, int> dummy2;
  1116. dummy.~MarkTypePair();
  1117. s0i.construct(&dummy, dummy2);
  1118. BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
  1119. BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
  1120. BOOST_TEST(dummy.first.value == 0);
  1121. BOOST_TEST(dummy.second.value == 0);
  1122. dummy.~MarkTypePair();
  1123. }
  1124. {
  1125. typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
  1126. typedef pair<MarkType, MarkType> MarkTypePair;
  1127. MarkTypePair dummy;
  1128. pair<int, int> dummy2(1, 1);
  1129. dummy.~MarkTypePair();
  1130. s0i.construct(&dummy, dummy2);
  1131. BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
  1132. BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
  1133. BOOST_TEST(dummy.first.value == 1);
  1134. BOOST_TEST(dummy.second.value == 1);
  1135. dummy.~MarkTypePair();
  1136. }
  1137. {
  1138. typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
  1139. typedef pair<MarkType, MarkType> MarkTypePair;
  1140. MarkTypePair dummy;
  1141. pair<int, int> dummy2(2, 2);
  1142. dummy.~MarkTypePair();
  1143. s0i.construct(&dummy, dummy2);
  1144. BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
  1145. BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
  1146. BOOST_TEST(dummy.first.value == 2);
  1147. BOOST_TEST(dummy.second.value == 2);
  1148. dummy.~MarkTypePair();
  1149. }
  1150. //Check construction with related pair move construction
  1151. {
  1152. typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
  1153. typedef pair<MarkType, MarkType> MarkTypePair;
  1154. MarkTypePair dummy;
  1155. pair<int, int> dummy2(3, 3);
  1156. dummy.~MarkTypePair();
  1157. s0i.construct(&dummy, ::boost::move(dummy2));
  1158. BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
  1159. BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
  1160. BOOST_TEST(dummy.first.value == 3);
  1161. BOOST_TEST(dummy.second.value == 3);
  1162. dummy.~MarkTypePair();
  1163. }
  1164. {
  1165. typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
  1166. typedef pair<MarkType, MarkType> MarkTypePair;
  1167. MarkTypePair dummy;
  1168. pair<int, int> dummy2(1, 1);
  1169. dummy.~MarkTypePair();
  1170. s0i.construct(&dummy, ::boost::move(dummy2));
  1171. BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
  1172. BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
  1173. BOOST_TEST(dummy.first.value == 1);
  1174. BOOST_TEST(dummy.second.value == 1);
  1175. dummy.~MarkTypePair();
  1176. }
  1177. {
  1178. typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
  1179. typedef pair<MarkType, MarkType> MarkTypePair;
  1180. MarkTypePair dummy;
  1181. pair<int, int> dummy2(2, 2);
  1182. dummy.~MarkTypePair();
  1183. s0i.construct(&dummy, ::boost::move(dummy2));
  1184. BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
  1185. BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
  1186. BOOST_TEST(dummy.first.value == 2);
  1187. BOOST_TEST(dummy.second.value == 2);
  1188. dummy.~MarkTypePair();
  1189. }
  1190. //Check construction with 0/1 arguments for each pair and Boost tuple
  1191. {
  1192. typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
  1193. typedef pair<MarkType, MarkType> MarkTypePair;
  1194. MarkTypePair dummy;
  1195. dummy.~MarkTypePair();
  1196. s0i.construct(&dummy, piecewise_construct, boost::tuple<>(), boost::tuple<int>(1));
  1197. BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
  1198. BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
  1199. BOOST_TEST(dummy.first.value == 0);
  1200. BOOST_TEST(dummy.second.value == 1);
  1201. dummy.~MarkTypePair();
  1202. }
  1203. {
  1204. typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
  1205. typedef pair<MarkType, MarkType> MarkTypePair;
  1206. MarkTypePair dummy;
  1207. dummy.~MarkTypePair();
  1208. s0i.construct(&dummy, piecewise_construct, boost::tuple<int>(1), boost::tuple<>());
  1209. BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
  1210. BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
  1211. BOOST_TEST(dummy.first.value == 1);
  1212. BOOST_TEST(dummy.second.value == 0);
  1213. dummy.~MarkTypePair();
  1214. }
  1215. {
  1216. typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
  1217. typedef pair<MarkType, MarkType> MarkTypePair;
  1218. MarkTypePair dummy;
  1219. dummy.~MarkTypePair();
  1220. s0i.construct(&dummy, piecewise_construct, boost::tuple<>(), boost::tuple<int>(2));
  1221. BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
  1222. BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
  1223. BOOST_TEST(dummy.first.value == 0);
  1224. BOOST_TEST(dummy.second.value == 2);
  1225. dummy.~MarkTypePair();
  1226. }
  1227. #if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
  1228. //Check construction with 0/1 arguments for each pair and Boost tuple
  1229. {
  1230. typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
  1231. typedef pair<MarkType, MarkType> MarkTypePair;
  1232. MarkTypePair dummy;
  1233. dummy.~MarkTypePair();
  1234. s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<int>(1));
  1235. BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
  1236. BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
  1237. BOOST_TEST(dummy.first.value == 0);
  1238. BOOST_TEST(dummy.second.value == 1);
  1239. dummy.~MarkTypePair();
  1240. }
  1241. {
  1242. typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
  1243. typedef pair<MarkType, MarkType> MarkTypePair;
  1244. MarkTypePair dummy;
  1245. dummy.~MarkTypePair();
  1246. s0i.construct(&dummy, piecewise_construct, std::tuple<int>(1), std::tuple<>());
  1247. BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
  1248. BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
  1249. BOOST_TEST(dummy.first.value == 1);
  1250. BOOST_TEST(dummy.second.value == 0);
  1251. dummy.~MarkTypePair();
  1252. }
  1253. {
  1254. typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
  1255. typedef pair<MarkType, MarkType> MarkTypePair;
  1256. MarkTypePair dummy;
  1257. dummy.~MarkTypePair();
  1258. s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<int>(2));
  1259. BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
  1260. BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
  1261. BOOST_TEST(dummy.first.value == 0);
  1262. BOOST_TEST(dummy.second.value == 2);
  1263. dummy.~MarkTypePair();
  1264. }
  1265. #endif //BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE
  1266. //Check construction with try_emplace_t 0/1 arguments for each pair
  1267. {
  1268. typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
  1269. typedef pair<MarkType, MarkType> MarkTypePair;
  1270. MarkTypePair dummy;
  1271. dummy.~MarkTypePair();
  1272. s0i.construct(&dummy, try_emplace_t(), 5, 1);
  1273. BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
  1274. BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
  1275. BOOST_TEST(dummy.first.value == 5);
  1276. BOOST_TEST(dummy.second.value == 1);
  1277. dummy.~MarkTypePair();
  1278. }
  1279. {
  1280. typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
  1281. typedef pair<MarkType, MarkType> MarkTypePair;
  1282. MarkTypePair dummy;
  1283. dummy.~MarkTypePair();
  1284. s0i.construct(&dummy, try_emplace_t(), 6);
  1285. BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
  1286. BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
  1287. BOOST_TEST(dummy.first.value == 6);
  1288. BOOST_TEST(dummy.second.value == 0);
  1289. dummy.~MarkTypePair();
  1290. }
  1291. {
  1292. typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
  1293. typedef pair<MarkType, MarkType> MarkTypePair;
  1294. MarkTypePair dummy;
  1295. dummy.~MarkTypePair();
  1296. s0i.construct(&dummy, try_emplace_t(), 7, 2);
  1297. BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
  1298. BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
  1299. BOOST_TEST(dummy.first.value == 7);
  1300. BOOST_TEST(dummy.second.value == 2);
  1301. dummy.~MarkTypePair();
  1302. }
  1303. }
  1304. }
  1305. return ::boost::report_errors();
  1306. }
  1307. #include <boost/container/detail/config_end.hpp>