123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377 |
- //////////////////////////////////////////////////////////////////////////////
- //
- // (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the Boost
- // Software License, Version 1.0. (See accompanying file
- // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- //
- // See http://www.boost.org/libs/container for documentation.
- //
- //////////////////////////////////////////////////////////////////////////////
- #include <boost/container/detail/config_begin.hpp>
- #include <boost/container/scoped_allocator_fwd.hpp>
- // container/detail
- #include <boost/container/detail/mpl.hpp>
- // move
- #include <boost/move/utility_core.hpp>
- #include <boost/move/adl_move_swap.hpp>
- //boost
- #include <boost/tuple/tuple.hpp>
- // std
- #include <memory>
- #include <cstddef>
- #if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
- #include <tuple>
- #endif
- //test
- #include <boost/core/lightweight_test.hpp>
- #include "allocator_argument_tester.hpp"
- template<unsigned int Type>
- struct tagged_integer
- {};
- struct mark_on_destructor
- {
- mark_on_destructor()
- {
- destroyed = false;
- }
- ~mark_on_destructor()
- {
- destroyed = true;
- }
- static bool destroyed;
- };
- bool mark_on_destructor::destroyed = false;
- #include <boost/container/scoped_allocator.hpp>
- #include <boost/static_assert.hpp>
- #include <boost/container/vector.hpp>
- #include <boost/container/detail/pair.hpp>
- int main()
- {
- using namespace boost::container;
- typedef propagation_test_allocator<tagged_integer<0>, 0> OuterAlloc;
- typedef propagation_test_allocator<tagged_integer<0>, 10> Outer10IdAlloc;
- typedef propagation_test_allocator<tagged_integer<9>, 0> Rebound9OuterAlloc;
- typedef propagation_test_allocator<tagged_integer<1>, 1> InnerAlloc1;
- typedef propagation_test_allocator<tagged_integer<2>, 2> InnerAlloc2;
- typedef propagation_test_allocator<tagged_integer<1>, 11> Inner11IdAlloc1;
- typedef propagation_test_allocator<tagged_integer<0>, 0, false> OuterAllocFalseHasTrueTypes;
- typedef propagation_test_allocator<tagged_integer<0>, 0, true> OuterAllocTrueHasTrueTypes;
- typedef propagation_test_allocator<tagged_integer<1>, 1, false> InnerAlloc1FalseHasTrueTypes;
- typedef propagation_test_allocator<tagged_integer<1>, 1, true> InnerAlloc1TrueHasTrueTypes;
- typedef propagation_test_allocator<tagged_integer<2>, 2, false> InnerAlloc2FalseHasTrueTypes;
- typedef propagation_test_allocator<tagged_integer<2>, 2, true> InnerAlloc2TrueHasTrueTypes;
- //
- typedef scoped_allocator_adaptor< OuterAlloc > Scoped0Inner;
- typedef scoped_allocator_adaptor< OuterAlloc
- , InnerAlloc1 > Scoped1Inner;
- typedef scoped_allocator_adaptor< OuterAlloc
- , InnerAlloc1
- , InnerAlloc2 > Scoped2Inner;
- typedef scoped_allocator_adaptor
- < scoped_allocator_adaptor
- <Outer10IdAlloc>
- > ScopedScoped0Inner;
- typedef scoped_allocator_adaptor
- < scoped_allocator_adaptor
- <Outer10IdAlloc, Inner11IdAlloc1>
- , InnerAlloc1
- > ScopedScoped1Inner;
- typedef scoped_allocator_adaptor< Rebound9OuterAlloc > Rebound9Scoped0Inner;
- typedef scoped_allocator_adaptor< Rebound9OuterAlloc
- , InnerAlloc1 > Rebound9Scoped1Inner;
- typedef scoped_allocator_adaptor< Rebound9OuterAlloc
- , InnerAlloc1
- , InnerAlloc2 > Rebound9Scoped2Inner;
- //outer_allocator_type
- BOOST_STATIC_ASSERT(( dtl::is_same< OuterAlloc
- , Scoped0Inner::outer_allocator_type>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same< OuterAlloc
- , Scoped1Inner::outer_allocator_type>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same< OuterAlloc
- , Scoped2Inner::outer_allocator_type>::value ));
- //value_type
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::value_type
- , Scoped0Inner::value_type>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::value_type
- , Scoped1Inner::value_type>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::value_type
- , Scoped2Inner::value_type>::value ));
- //size_type
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::size_type
- , Scoped0Inner::size_type>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::size_type
- , Scoped1Inner::size_type>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::size_type
- , Scoped2Inner::size_type>::value ));
- //difference_type
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::difference_type
- , Scoped0Inner::difference_type>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::difference_type
- , Scoped1Inner::difference_type>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::difference_type
- , Scoped2Inner::difference_type>::value ));
- //pointer
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::pointer
- , Scoped0Inner::pointer>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::pointer
- , Scoped1Inner::pointer>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::pointer
- , Scoped2Inner::pointer>::value ));
- //const_pointer
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::const_pointer
- , Scoped0Inner::const_pointer>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::const_pointer
- , Scoped1Inner::const_pointer>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::const_pointer
- , Scoped2Inner::const_pointer>::value ));
- //void_pointer
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::void_pointer
- , Scoped0Inner::void_pointer>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::void_pointer
- , Scoped1Inner::void_pointer>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::void_pointer
- , Scoped2Inner::void_pointer>::value ));
- //const_void_pointer
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::const_void_pointer
- , Scoped0Inner::const_void_pointer>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::const_void_pointer
- , Scoped1Inner::const_void_pointer>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::const_void_pointer
- , Scoped2Inner::const_void_pointer>::value ));
- //rebind
- BOOST_STATIC_ASSERT(( dtl::is_same<Scoped0Inner::rebind< tagged_integer<9> >::other
- , Rebound9Scoped0Inner >::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same<Scoped1Inner::rebind< tagged_integer<9> >::other
- , Rebound9Scoped1Inner >::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same<Scoped2Inner::rebind< tagged_integer<9> >::other
- , Rebound9Scoped2Inner >::value ));
- //inner_allocator_type
- BOOST_STATIC_ASSERT(( dtl::is_same< Scoped0Inner
- , Scoped0Inner::inner_allocator_type>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same< scoped_allocator_adaptor<InnerAlloc1>
- , Scoped1Inner::inner_allocator_type>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same< scoped_allocator_adaptor<InnerAlloc1, InnerAlloc2>
- , Scoped2Inner::inner_allocator_type>::value ));
- {
- //Propagation test
- typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes > Scoped0InnerF;
- typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes > Scoped0InnerT;
- typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes
- , InnerAlloc1FalseHasTrueTypes > Scoped1InnerFF;
- typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes
- , InnerAlloc1TrueHasTrueTypes > Scoped1InnerFT;
- typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes
- , InnerAlloc1FalseHasTrueTypes > Scoped1InnerTF;
- typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes
- , InnerAlloc1TrueHasTrueTypes > Scoped1InnerTT;
- typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes
- , InnerAlloc1FalseHasTrueTypes
- , InnerAlloc2FalseHasTrueTypes > Scoped2InnerFFF;
- typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes
- , InnerAlloc1FalseHasTrueTypes
- , InnerAlloc2TrueHasTrueTypes > Scoped2InnerFFT;
- typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes
- , InnerAlloc1TrueHasTrueTypes
- , InnerAlloc2FalseHasTrueTypes > Scoped2InnerFTF;
- typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes
- , InnerAlloc1TrueHasTrueTypes
- , InnerAlloc2TrueHasTrueTypes > Scoped2InnerFTT;
- typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes
- , InnerAlloc1FalseHasTrueTypes
- , InnerAlloc2FalseHasTrueTypes > Scoped2InnerTFF;
- typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes
- , InnerAlloc1FalseHasTrueTypes
- , InnerAlloc2TrueHasTrueTypes > Scoped2InnerTFT;
- typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes
- , InnerAlloc1TrueHasTrueTypes
- , InnerAlloc2FalseHasTrueTypes > Scoped2InnerTTF;
- typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes
- , InnerAlloc1TrueHasTrueTypes
- , InnerAlloc2TrueHasTrueTypes > Scoped2InnerTTT;
- //propagate_on_container_copy_assignment
- //0 inner
- BOOST_STATIC_ASSERT(( !Scoped0InnerF::propagate_on_container_copy_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped0InnerT::propagate_on_container_copy_assignment::value ));
- //1 inner
- BOOST_STATIC_ASSERT(( !Scoped1InnerFF::propagate_on_container_copy_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped1InnerFT::propagate_on_container_copy_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped1InnerTF::propagate_on_container_copy_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped1InnerTT::propagate_on_container_copy_assignment::value ));
- //2 inner
- BOOST_STATIC_ASSERT(( !Scoped2InnerFFF::propagate_on_container_copy_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerFFT::propagate_on_container_copy_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerFTF::propagate_on_container_copy_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerFTT::propagate_on_container_copy_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerTFF::propagate_on_container_copy_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerTFT::propagate_on_container_copy_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerTTF::propagate_on_container_copy_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerTTT::propagate_on_container_copy_assignment::value ));
- //propagate_on_container_move_assignment
- //0 inner
- BOOST_STATIC_ASSERT(( !Scoped0InnerF::propagate_on_container_move_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped0InnerT::propagate_on_container_move_assignment::value ));
- //1 inner
- BOOST_STATIC_ASSERT(( !Scoped1InnerFF::propagate_on_container_move_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped1InnerFT::propagate_on_container_move_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped1InnerTF::propagate_on_container_move_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped1InnerTT::propagate_on_container_move_assignment::value ));
- //2 inner
- BOOST_STATIC_ASSERT(( !Scoped2InnerFFF::propagate_on_container_move_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerFFT::propagate_on_container_move_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerFTF::propagate_on_container_move_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerFTT::propagate_on_container_move_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerTFF::propagate_on_container_move_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerTFT::propagate_on_container_move_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerTTF::propagate_on_container_move_assignment::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerTTT::propagate_on_container_move_assignment::value ));
- //propagate_on_container_swap
- //0 inner
- BOOST_STATIC_ASSERT(( !Scoped0InnerF::propagate_on_container_swap::value ));
- BOOST_STATIC_ASSERT(( Scoped0InnerT::propagate_on_container_swap::value ));
- //1 inner
- BOOST_STATIC_ASSERT(( !Scoped1InnerFF::propagate_on_container_swap::value ));
- BOOST_STATIC_ASSERT(( Scoped1InnerFT::propagate_on_container_swap::value ));
- BOOST_STATIC_ASSERT(( Scoped1InnerTF::propagate_on_container_swap::value ));
- BOOST_STATIC_ASSERT(( Scoped1InnerTT::propagate_on_container_swap::value ));
- //2 inner
- BOOST_STATIC_ASSERT(( !Scoped2InnerFFF::propagate_on_container_swap::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerFFT::propagate_on_container_swap::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerFTF::propagate_on_container_swap::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerFTT::propagate_on_container_swap::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerTFF::propagate_on_container_swap::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerTFT::propagate_on_container_swap::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerTTF::propagate_on_container_swap::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerTTT::propagate_on_container_swap::value ));
- //is_always_equal
- //0 inner
- BOOST_STATIC_ASSERT(( !Scoped0InnerF::is_always_equal::value ));
- BOOST_STATIC_ASSERT(( Scoped0InnerT::is_always_equal::value ));
- //1 inner
- BOOST_STATIC_ASSERT(( !Scoped1InnerFF::is_always_equal::value ));
- BOOST_STATIC_ASSERT(( !Scoped1InnerFT::is_always_equal::value ));
- BOOST_STATIC_ASSERT(( !Scoped1InnerTF::is_always_equal::value ));
- BOOST_STATIC_ASSERT(( Scoped1InnerTT::is_always_equal::value ));
- //2 inner
- BOOST_STATIC_ASSERT(( !Scoped2InnerFFF::is_always_equal::value ));
- BOOST_STATIC_ASSERT(( !Scoped2InnerFFT::is_always_equal::value ));
- BOOST_STATIC_ASSERT(( !Scoped2InnerFTF::is_always_equal::value ));
- BOOST_STATIC_ASSERT(( !Scoped2InnerFTT::is_always_equal::value ));
- BOOST_STATIC_ASSERT(( !Scoped2InnerTFF::is_always_equal::value ));
- BOOST_STATIC_ASSERT(( !Scoped2InnerTFT::is_always_equal::value ));
- BOOST_STATIC_ASSERT(( !Scoped2InnerTTF::is_always_equal::value ));
- BOOST_STATIC_ASSERT(( Scoped2InnerTTT::is_always_equal::value ));
- }
- //Default constructor
- {
- Scoped0Inner s0i;
- Scoped1Inner s1i;
- //Swap
- {
- Scoped0Inner s0i2;
- Scoped1Inner s1i2;
- boost::adl_move_swap(s0i, s0i2);
- boost::adl_move_swap(s1i, s1i2);
- }
- }
- //Default constructor
- {
- Scoped0Inner s0i;
- Scoped1Inner s1i;
- }
- //Copy constructor/assignment
- {
- Scoped0Inner s0i;
- Scoped1Inner s1i;
- Scoped2Inner s2i;
- Scoped0Inner s0i_b(s0i);
- Scoped1Inner s1i_b(s1i);
- Scoped2Inner s2i_b(s2i);
- BOOST_TEST(s0i == s0i_b);
- BOOST_TEST(s1i == s1i_b);
- BOOST_TEST(s2i == s2i_b);
- s0i_b = s0i;
- s1i_b = s1i;
- s2i_b = s2i;
- BOOST_TEST(s0i == s0i_b);
- BOOST_TEST(s1i == s1i_b);
- BOOST_TEST(s2i == s2i_b);
- }
- //Copy/move constructor/assignment
- {
- Scoped0Inner s0i;
- Scoped1Inner s1i;
- Scoped2Inner s2i;
- Scoped0Inner s0i_b(::boost::move(s0i));
- Scoped1Inner s1i_b(::boost::move(s1i));
- Scoped2Inner s2i_b(::boost::move(s2i));
- BOOST_TEST(s0i_b.outer_allocator().m_move_contructed);
- BOOST_TEST(s1i_b.outer_allocator().m_move_contructed);
- BOOST_TEST(s2i_b.outer_allocator().m_move_contructed);
- s0i_b = ::boost::move(s0i);
- s1i_b = ::boost::move(s1i);
- s2i_b = ::boost::move(s2i);
- BOOST_TEST(s0i_b.outer_allocator().m_move_assigned);
- BOOST_TEST(s1i_b.outer_allocator().m_move_assigned);
- BOOST_TEST(s2i_b.outer_allocator().m_move_assigned);
- }
- //inner_allocator()
- {
- Scoped0Inner s0i;
- Scoped1Inner s1i;
- Scoped2Inner s2i;
- const Scoped0Inner const_s0i;
- const Scoped1Inner const_s1i;
- const Scoped2Inner const_s2i;
- Scoped0Inner::inner_allocator_type &s0i_inner = s0i.inner_allocator();
- (void)s0i_inner;
- const Scoped0Inner::inner_allocator_type &const_s0i_inner = const_s0i.inner_allocator();
- (void)const_s0i_inner;
- Scoped1Inner::inner_allocator_type &s1i_inner = s1i.inner_allocator();
- (void)s1i_inner;
- const Scoped1Inner::inner_allocator_type &const_s1i_inner = const_s1i.inner_allocator();
- (void)const_s1i_inner;
- Scoped2Inner::inner_allocator_type &s2i_inner = s2i.inner_allocator();
- (void)s2i_inner;
- const Scoped2Inner::inner_allocator_type &const_s2i_inner = const_s2i.inner_allocator();
- (void)const_s2i_inner;
- }
- //operator==/!=
- {
- const Scoped0Inner const_s0i;
- const Rebound9Scoped0Inner const_rs0i;
- BOOST_TEST(const_s0i == const_s0i);
- BOOST_TEST(const_rs0i == const_s0i);
- BOOST_TEST(const_s0i == const_s0i);
- BOOST_TEST(const_s0i == const_rs0i);
- const Scoped1Inner const_s1i;
- const Rebound9Scoped1Inner const_rs1i;
- BOOST_TEST(const_s1i == const_s1i);
- BOOST_TEST(const_rs1i == const_s1i);
- BOOST_TEST(const_s1i == const_s1i);
- BOOST_TEST(const_s1i == const_rs1i);
- const Scoped2Inner const_s2i;
- const Rebound9Scoped2Inner const_rs2i;
- BOOST_TEST(const_s2i == const_s2i);
- BOOST_TEST(const_s2i == const_rs2i);
- BOOST_TEST(const_s2i == const_s2i);
- BOOST_TEST(const_s2i == const_rs2i);
- }
- //outer_allocator()
- {
- Scoped0Inner s0i;
- Scoped1Inner s1i;
- Scoped2Inner s2i;
- const Scoped0Inner const_s0i;
- const Scoped1Inner const_s1i;
- const Scoped2Inner const_s2i;
- Scoped0Inner::outer_allocator_type &s0i_inner = s0i.outer_allocator();
- (void)s0i_inner;
- const Scoped0Inner::outer_allocator_type &const_s0i_inner = const_s0i.outer_allocator();
- (void)const_s0i_inner;
- Scoped1Inner::outer_allocator_type &s1i_inner = s1i.outer_allocator();
- (void)s1i_inner;
- const Scoped1Inner::outer_allocator_type &const_s1i_inner = const_s1i.outer_allocator();
- (void)const_s1i_inner;
- Scoped2Inner::outer_allocator_type &s2i_inner = s2i.outer_allocator();
- (void)s2i_inner;
- const Scoped2Inner::outer_allocator_type &const_s2i_inner = const_s2i.outer_allocator();
- (void)const_s2i_inner;
- }
- //max_size()
- {
- const Scoped0Inner const_s0i;
- const Scoped1Inner const_s1i;
- const Scoped2Inner const_s2i;
- const OuterAlloc const_oa;
- const InnerAlloc1 const_ia1;
- const InnerAlloc2 const_ia2;
- BOOST_TEST(const_s0i.max_size() == const_oa.max_size());
- BOOST_TEST(const_s1i.max_size() == const_oa.max_size());
- BOOST_TEST(const_s2i.max_size() == const_oa.max_size());
- BOOST_TEST(const_s1i.inner_allocator().max_size() == const_ia1.max_size());
- BOOST_TEST(const_s2i.inner_allocator().inner_allocator().max_size() == const_ia2.max_size());
- }
- //Copy and move operations
- {
- //Construction
- {
- Scoped0Inner s0i_a, s0i_b(s0i_a), s0i_c(::boost::move(s0i_b));
- Scoped1Inner s1i_a, s1i_b(s1i_a), s1i_c(::boost::move(s1i_b));
- Scoped2Inner s2i_a, s2i_b(s2i_a), s2i_c(::boost::move(s2i_b));
- }
- //Assignment
- {
- Scoped0Inner s0i_a, s0i_b;
- s0i_a = s0i_b;
- s0i_a = ::boost::move(s0i_b);
- Scoped1Inner s1i_a, s1i_b;
- s1i_a = s1i_b;
- s1i_a = ::boost::move(s1i_b);
- Scoped2Inner s2i_a, s2i_b;
- s2i_a = s2i_b;
- s2i_a = ::boost::move(s2i_b);
- }
- OuterAlloc oa;
- InnerAlloc1 ia1;
- InnerAlloc2 ia2;
- Rebound9OuterAlloc roa;
- Rebound9Scoped0Inner rs0i;
- Rebound9Scoped1Inner rs1i;
- Rebound9Scoped2Inner rs2i;
- //Copy from outer
- {
- Scoped0Inner s0i(oa);
- Scoped1Inner s1i(oa, ia1);
- Scoped2Inner s2i(oa, ia1, ia2);
- }
- //Move from outer
- {
- Scoped0Inner s0i(::boost::move(oa));
- Scoped1Inner s1i(::boost::move(oa), ia1);
- Scoped2Inner s2i(::boost::move(oa), ia1, ia2);
- }
- //Copy from rebound outer
- {
- Scoped0Inner s0i(roa);
- Scoped1Inner s1i(roa, ia1);
- Scoped2Inner s2i(roa, ia1, ia2);
- }
- //Move from rebound outer
- {
- Scoped0Inner s0i(::boost::move(roa));
- Scoped1Inner s1i(::boost::move(roa), ia1);
- Scoped2Inner s2i(::boost::move(roa), ia1, ia2);
- }
- //Copy from rebound scoped
- {
- Scoped0Inner s0i(rs0i);
- Scoped1Inner s1i(rs1i);
- Scoped2Inner s2i(rs2i);
- }
- //Move from rebound scoped
- {
- Scoped0Inner s0i(::boost::move(rs0i));
- Scoped1Inner s1i(::boost::move(rs1i));
- Scoped2Inner s2i(::boost::move(rs2i));
- }
- }
- {
- vector<int, scoped_allocator_adaptor< propagation_test_allocator<int, 0> > > dummy;
- dummy.push_back(0);
- }
- //destroy()
- {
- {
- Scoped0Inner s0i;
- mark_on_destructor mod;
- s0i.destroy(&mod);
- BOOST_TEST(mark_on_destructor::destroyed);
- }
- {
- Scoped1Inner s1i;
- mark_on_destructor mod;
- s1i.destroy(&mod);
- BOOST_TEST(mark_on_destructor::destroyed);
- }
- {
- Scoped2Inner s2i;
- mark_on_destructor mod;
- s2i.destroy(&mod);
- BOOST_TEST(mark_on_destructor::destroyed);
- }
- }
- //construct
- {
- ////////////////////////////////////////////////////////////
- //First check scoped allocator with just OuterAlloc.
- //In this case OuterAlloc (propagation_test_allocator with tag 0) should be
- //used to construct types.
- ////////////////////////////////////////////////////////////
- {
- Scoped0Inner s0i;
- //Check construction with 0 user arguments
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- s0i.construct(&dummy);
- BOOST_TEST(dummy.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.value == 0 );
- dummy.~MarkType();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- s0i.construct(&dummy);
- BOOST_TEST(dummy.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.value == 0);
- dummy.~MarkType();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- s0i.construct(&dummy);
- BOOST_TEST(dummy.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.value == 0);
- dummy.~MarkType();
- }
- //Check construction with 1 user arguments
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- s0i.construct(&dummy, 1);
- BOOST_TEST(dummy.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.value == 1);
- dummy.~MarkType();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- s0i.construct(&dummy, 2);
- BOOST_TEST(dummy.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.value == 2);
- dummy.~MarkType();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- s0i.construct(&dummy, 3);
- BOOST_TEST(dummy.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.value == 3);
- dummy.~MarkType();
- }
- }
- ////////////////////////////////////////////////////////////
- //Then check scoped allocator with OuterAlloc and InnerAlloc.
- //In this case InnerAlloc (propagation_test_allocator with tag 1) should be
- //used to construct types.
- ////////////////////////////////////////////////////////////
- {
- Scoped1Inner s1i;
- //Check construction with 0 user arguments
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 1> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- s1i.construct(&dummy);
- BOOST_TEST(dummy.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.value == 0);
- dummy.~MarkType();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 1> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- s1i.construct(&dummy);
- BOOST_TEST(dummy.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.value == 0);
- dummy.~MarkType();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 1> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- s1i.construct(&dummy);
- BOOST_TEST(dummy.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.value == 0);
- dummy.~MarkType();
- }
- //Check construction with 1 user arguments
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 1> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- s1i.construct(&dummy, 1);
- BOOST_TEST(dummy.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.value == 1);
- dummy.~MarkType();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 1> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- s1i.construct(&dummy, 2);
- BOOST_TEST(dummy.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.value == 2);
- dummy.~MarkType();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 1> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- s1i.construct(&dummy, 3);
- BOOST_TEST(dummy.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.value == 3);
- dummy.~MarkType();
- }
- }
- //////////////////////////////////////////////////////////////////////////////////
- //Now test recursive OuterAllocator types (OuterAllocator is a scoped_allocator)
- //////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////
- //First check scoped allocator with just OuterAlloc.
- //In this case OuterAlloc (propagation_test_allocator with tag 0) should be
- //used to construct types.
- ////////////////////////////////////////////////////////////
- {
- //Check outer_allocator_type is scoped
- BOOST_STATIC_ASSERT(( is_scoped_allocator
- <ScopedScoped0Inner::outer_allocator_type>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same
- < outermost_allocator<ScopedScoped0Inner>::type
- , Outer10IdAlloc
- >::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same
- < ScopedScoped0Inner::outer_allocator_type
- , scoped_allocator_adaptor<Outer10IdAlloc>
- >::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same
- < scoped_allocator_adaptor<Outer10IdAlloc>::outer_allocator_type
- , Outer10IdAlloc
- >::value ));
- ScopedScoped0Inner ssro0i;
- Outer10IdAlloc & val = outermost_allocator<ScopedScoped0Inner>::get(ssro0i);
- (void)val;
- //Check construction with 0 user arguments
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 10> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- ssro0i.construct(&dummy);
- BOOST_TEST(dummy.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.value == 0);
- dummy.~MarkType();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 10> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- ssro0i.construct(&dummy);
- BOOST_TEST(dummy.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.value == 0);
- dummy.~MarkType();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 10> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- ssro0i.construct(&dummy);
- BOOST_TEST(dummy.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.value == 0);
- dummy.~MarkType();
- }
- //Check construction with 1 user arguments
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 10> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- ssro0i.construct(&dummy, 1);
- BOOST_TEST(dummy.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.value == 1);
- dummy.~MarkType();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 10> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- ssro0i.construct(&dummy, 2);
- BOOST_TEST(dummy.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.value == 2);
- dummy.~MarkType();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 10> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- ssro0i.construct(&dummy, 3);
- BOOST_TEST(dummy.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.value == 3);
- dummy.~MarkType();
- }
- }
- ////////////////////////////////////////////////////////////
- //Then check scoped allocator with OuterAlloc and InnerAlloc.
- //In this case inner_allocator_type is not convertible to
- //::allocator_argument_tester<XXX, 10> so uses_allocator
- //should be false on all tests.
- ////////////////////////////////////////////////////////////
- {
- //Check outer_allocator_type is scoped
- BOOST_STATIC_ASSERT(( is_scoped_allocator
- <ScopedScoped1Inner::outer_allocator_type>::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same
- < outermost_allocator<ScopedScoped1Inner>::type
- , Outer10IdAlloc
- >::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same
- < ScopedScoped1Inner::outer_allocator_type
- , scoped_allocator_adaptor<Outer10IdAlloc, Inner11IdAlloc1>
- >::value ));
- BOOST_STATIC_ASSERT(( dtl::is_same
- < scoped_allocator_adaptor<Outer10IdAlloc, Inner11IdAlloc1>::outer_allocator_type
- , Outer10IdAlloc
- >::value ));
- BOOST_STATIC_ASSERT(( !
- uses_allocator
- < ::allocator_argument_tester<ConstructibleSuffix, 10>
- , ScopedScoped1Inner::inner_allocator_type::outer_allocator_type
- >::value ));
- ScopedScoped1Inner ssro1i;
- Outer10IdAlloc & val = outermost_allocator<ScopedScoped1Inner>::get(ssro1i);
- (void)val;
- //Check construction with 0 user arguments
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 10> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- ssro1i.construct(&dummy);
- BOOST_TEST(dummy.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.value == 0);
- dummy.~MarkType();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 10> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- ssro1i.construct(&dummy);
- BOOST_TEST(dummy.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.value == 0);
- dummy.~MarkType();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 10> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- ssro1i.construct(&dummy);
- BOOST_TEST(dummy.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.value == 0);
- dummy.~MarkType();
- }
- //Check construction with 1 user arguments
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 10> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- ssro1i.construct(&dummy, 1);
- BOOST_TEST(dummy.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.value == 1);
- dummy.~MarkType();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 10> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- ssro1i.construct(&dummy, 2);
- BOOST_TEST(dummy.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.value == 2);
- dummy.~MarkType();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 10> MarkType;
- MarkType dummy;
- dummy.~MarkType();
- ssro1i.construct(&dummy, 3);
- BOOST_TEST(dummy.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.value == 3);
- dummy.~MarkType();
- }
- }
- ////////////////////////////////////////////////////////////
- //Now check propagation to pair
- ////////////////////////////////////////////////////////////
- //First check scoped allocator with just OuterAlloc.
- //In this case OuterAlloc (propagation_test_allocator with tag 0) should be
- //used to construct types.
- ////////////////////////////////////////////////////////////
- {
- using dtl::pair;
- typedef propagation_test_allocator< pair< tagged_integer<0>
- , tagged_integer<0> >, 0> OuterPairAlloc;
- //
- typedef scoped_allocator_adaptor < OuterPairAlloc > ScopedPair0Inner;
- ScopedPair0Inner s0i;
- //Check construction with 0 user arguments
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy);
- BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.first.value == 0);
- BOOST_TEST(dummy.second.value == 0);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy);
- BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.first.value == 0);
- BOOST_TEST(dummy.second.value == 0);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy);
- BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.first.value == 0);
- BOOST_TEST(dummy.second.value == 0);
- dummy.~MarkTypePair();
- }
- #if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
- //Check construction with 0 user arguments and Std tuple
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<>());
- BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.first.value == 0);
- BOOST_TEST(dummy.second.value == 0);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<>());
- BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.first.value == 0);
- BOOST_TEST(dummy.second.value == 0);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<>());
- BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.first.value == 0);
- BOOST_TEST(dummy.second.value == 0);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<>());
- BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.first.value == 0);
- BOOST_TEST(dummy.second.value == 0);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<>());
- BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.first.value == 0);
- BOOST_TEST(dummy.second.value == 0);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<>());
- BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.first.value == 0);
- BOOST_TEST(dummy.second.value == 0);
- dummy.~MarkTypePair();
- }
- #endif //BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE
- //Check construction with 1 user arguments for each pair
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, 1, 1);
- BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.first.value == 1);
- BOOST_TEST(dummy.second.value == 1);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, 1, 1);
- BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.first.value == 1);
- BOOST_TEST(dummy.second.value == 1);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, 2, 2);
- BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.first.value == 2);
- BOOST_TEST(dummy.second.value == 2);
- dummy.~MarkTypePair();
- }
- //Check construction with 1 user arguments for each pair and Boost tuple
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, piecewise_construct, boost::tuple<int>(1), boost::tuple<int>(1));
- BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.first.value == 1);
- BOOST_TEST(dummy.second.value == 1);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, piecewise_construct, boost::tuple<int>(1), boost::tuple<int>(1));
- BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.first.value == 1);
- BOOST_TEST(dummy.second.value == 1);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, piecewise_construct, boost::tuple<int>(2), boost::tuple<int>(2));
- BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.first.value == 2);
- BOOST_TEST(dummy.second.value == 2);
- dummy.~MarkTypePair();
- }
- #if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
- //Check construction with 1 user arguments for each pair and Boost tuple
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, piecewise_construct, std::tuple<int>(1), std::tuple<int>(1));
- BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.first.value == 1);
- BOOST_TEST(dummy.second.value == 1);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, piecewise_construct, std::tuple<int>(1), std::tuple<int>(1));
- BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.first.value == 1);
- BOOST_TEST(dummy.second.value == 1);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, piecewise_construct, std::tuple<int>(2), std::tuple<int>(2));
- BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.first.value == 2);
- BOOST_TEST(dummy.second.value == 2);
- dummy.~MarkTypePair();
- }
- #endif //BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE
- //Check construction with pair copy construction
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy, dummy2;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, dummy2);
- BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.first.value == 0);
- BOOST_TEST(dummy.second.value == 0);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy, dummy2(1, 1);
- dummy.~MarkTypePair();
- s0i.construct(&dummy, dummy2);
- BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.first.value == 1);
- BOOST_TEST(dummy.second.value == 1);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy, dummy2(2, 2);
- dummy.~MarkTypePair();
- s0i.construct(&dummy, dummy2);
- BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.first.value == 2);
- BOOST_TEST(dummy.second.value == 2);
- dummy.~MarkTypePair();
- }
- //Check construction with pair move construction
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy, dummy2(3, 3);
- dummy2.first.construction_type = dummy2.second.construction_type = ConstructibleSuffix;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, ::boost::move(dummy2));
- BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.first.value == 3);
- BOOST_TEST(dummy.second.value == 3);
- BOOST_TEST(dummy2.first.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy2.second.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy2.first.value == 0);
- BOOST_TEST(dummy2.second.value == 0);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy, dummy2(1, 1);
- dummy.~MarkTypePair();
- s0i.construct(&dummy, ::boost::move(dummy2));
- BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.first.value == 1);
- BOOST_TEST(dummy.second.value == 1);
- BOOST_TEST(dummy2.first.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy2.second.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy2.first.value == 0);
- BOOST_TEST(dummy2.second.value == 0);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy, dummy2(2, 2);
- dummy.~MarkTypePair();
- s0i.construct(&dummy, ::boost::move(dummy2));
- BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.first.value == 2);
- BOOST_TEST(dummy.second.value == 2);
- BOOST_TEST(dummy2.first.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy2.second.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy2.first.value == 0);
- BOOST_TEST(dummy2.second.value == 0);
- dummy.~MarkTypePair();
- }
- //Check construction with related pair copy construction
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- pair<int, int> dummy2;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, dummy2);
- BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.first.value == 0);
- BOOST_TEST(dummy.second.value == 0);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- pair<int, int> dummy2(1, 1);
- dummy.~MarkTypePair();
- s0i.construct(&dummy, dummy2);
- BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.first.value == 1);
- BOOST_TEST(dummy.second.value == 1);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- pair<int, int> dummy2(2, 2);
- dummy.~MarkTypePair();
- s0i.construct(&dummy, dummy2);
- BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.first.value == 2);
- BOOST_TEST(dummy.second.value == 2);
- dummy.~MarkTypePair();
- }
- //Check construction with related pair move construction
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- pair<int, int> dummy2(3, 3);
- dummy.~MarkTypePair();
- s0i.construct(&dummy, ::boost::move(dummy2));
- BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.first.value == 3);
- BOOST_TEST(dummy.second.value == 3);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- pair<int, int> dummy2(1, 1);
- dummy.~MarkTypePair();
- s0i.construct(&dummy, ::boost::move(dummy2));
- BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.first.value == 1);
- BOOST_TEST(dummy.second.value == 1);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- pair<int, int> dummy2(2, 2);
- dummy.~MarkTypePair();
- s0i.construct(&dummy, ::boost::move(dummy2));
- BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.first.value == 2);
- BOOST_TEST(dummy.second.value == 2);
- dummy.~MarkTypePair();
- }
- //Check construction with 0/1 arguments for each pair and Boost tuple
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, piecewise_construct, boost::tuple<>(), boost::tuple<int>(1));
- BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.first.value == 0);
- BOOST_TEST(dummy.second.value == 1);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, piecewise_construct, boost::tuple<int>(1), boost::tuple<>());
- BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.first.value == 1);
- BOOST_TEST(dummy.second.value == 0);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, piecewise_construct, boost::tuple<>(), boost::tuple<int>(2));
- BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.first.value == 0);
- BOOST_TEST(dummy.second.value == 2);
- dummy.~MarkTypePair();
- }
- #if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
- //Check construction with 0/1 arguments for each pair and Boost tuple
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<int>(1));
- BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.first.value == 0);
- BOOST_TEST(dummy.second.value == 1);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, piecewise_construct, std::tuple<int>(1), std::tuple<>());
- BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.first.value == 1);
- BOOST_TEST(dummy.second.value == 0);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<int>(2));
- BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.first.value == 0);
- BOOST_TEST(dummy.second.value == 2);
- dummy.~MarkTypePair();
- }
- #endif //BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE
- //Check construction with try_emplace_t 0/1 arguments for each pair
- {
- typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, try_emplace_t(), 5, 1);
- BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
- BOOST_TEST(dummy.first.value == 5);
- BOOST_TEST(dummy.second.value == 1);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, try_emplace_t(), 6);
- BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
- BOOST_TEST(dummy.first.value == 6);
- BOOST_TEST(dummy.second.value == 0);
- dummy.~MarkTypePair();
- }
- {
- typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
- typedef pair<MarkType, MarkType> MarkTypePair;
- MarkTypePair dummy;
- dummy.~MarkTypePair();
- s0i.construct(&dummy, try_emplace_t(), 7, 2);
- BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
- BOOST_TEST(dummy.first.value == 7);
- BOOST_TEST(dummy.second.value == 2);
- dummy.~MarkTypePair();
- }
- }
- }
- return ::boost::report_errors();
- }
- #include <boost/container/detail/config_end.hpp>
|