12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381 |
- // Boost.TypeErasure library
- //
- // Copyright 2011 Steven Watanabe
- //
- // 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)
- //
- // $Id$
- #include <boost/config.hpp>
- #ifdef BOOST_MSVC
- #pragma warning(disable:4244) // conversion from double to int
- #endif
- #include <boost/type_erasure/any.hpp>
- #include <boost/type_erasure/tuple.hpp>
- #include <boost/type_erasure/builtin.hpp>
- #include <boost/type_erasure/operators.hpp>
- #include <boost/type_erasure/any_cast.hpp>
- #include <boost/type_erasure/relaxed.hpp>
- #include <boost/mpl/vector.hpp>
- #define BOOST_TEST_MAIN
- #include <boost/test/unit_test.hpp>
- using namespace boost::type_erasure;
- using boost::core::demangle;
- template<class T = _self>
- struct common : ::boost::mpl::vector<
- copy_constructible<T>,
- typeid_<T>
- > {};
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- template<class T = _self>
- struct movable_common : ::boost::mpl::vector<
- destructible<T>,
- constructible<T(T&&)>,
- typeid_<T>
- > {};
- template<class T = _self, class U = T>
- struct move_assignable : ::boost::mpl::vector<
- assignable<T, U&&>
- > {};
- #endif
- template<class T, bool CCtor, bool MoveCtor, bool CAssign, bool MoveAssign>
- struct test_class
- {
- explicit test_class(T n) : value(n) {}
- test_class(const test_class& src) : value(src.value)
- {
- BOOST_STATIC_ASSERT_MSG(CCtor, "Copy constructor not allowed.");
- }
- test_class& operator=(const test_class& src)
- {
- BOOST_STATIC_ASSERT_MSG(CAssign, "Copy assignment not allowed.");
- value = src.value;
- return *this;
- }
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- test_class(test_class&& src) : value(src.value)
- {
- BOOST_STATIC_ASSERT_MSG(MoveCtor, "Move constructor not allowed.");
- src.value = 0;
- }
- test_class& operator=(test_class&& src)
- {
- BOOST_STATIC_ASSERT_MSG(MoveAssign, "Move assignment not allowed.");
- value = src.value;
- src.value = 0;
- return *this;
- }
- #endif
- bool operator==(T n) const { return value == n; }
- T value;
- };
- template<class T, bool CCtor, bool MoveCtor, bool CAssign, bool MoveAssign>
- std::ostream& operator<<(std::ostream& os, const test_class<T, CCtor, MoveCtor, CAssign, MoveAssign>& t)
- {
- return os << t.value;
- }
- enum copy_info {
- id_lvalue = 1,
- id_const_lvalue = 2,
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- id_rvalue = 3,
- id_maybe_const_lvalue = id_lvalue, // used for the id of construction from a raw value
- #else
- id_rvalue = id_const_lvalue,
- id_maybe_const_lvalue = id_const_lvalue,
- #endif
- id_construct = 4,
- id_assign = 8,
- id_copy = 16,
- id_int = 32
- };
- #ifdef BOOST_MSVC
- #pragma warning(disable:4521) // multiple copy constructors specified
- #pragma warning(disable:4522) // multiple assignment operators specified
- #endif
- template<class T>
- struct copy_tracker
- {
- copy_tracker(const copy_tracker& src) : value(src.value), info(id_const_lvalue | id_construct | id_copy), moved_from(false) {}
- copy_tracker(copy_tracker& src) : value(src.value), info(id_lvalue | id_construct | id_copy), moved_from(false) {}
- copy_tracker& operator=(const copy_tracker& src) { value = (src.value); info = (id_const_lvalue | id_assign | id_copy); moved_from = false; return *this; }
- copy_tracker& operator=(copy_tracker& src) { value = (src.value); info = (id_lvalue | id_assign | id_copy); moved_from = false; return *this; }
- copy_tracker(const T& src) : value(src), info(id_const_lvalue | id_construct | id_int), moved_from(false) {}
- copy_tracker(T& src) : value(src), info(id_lvalue | id_construct | id_int), moved_from(false) {}
- copy_tracker& operator=(const T& src) { value = (src); info = (id_const_lvalue | id_assign | id_int); moved_from = false; return *this; }
- copy_tracker& operator=(T& src) { value = (src); info = (id_lvalue | id_assign | id_int); moved_from = false; return *this; }
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- copy_tracker(copy_tracker&& src) : value(std::move(src.value)), info(id_rvalue | id_construct | id_copy), moved_from(false) { src.moved_from = true; }
- copy_tracker& operator=(copy_tracker&& src) { value = std::move(src.value); info = (id_rvalue | id_assign | id_copy); moved_from = false; src.moved_from = true; return *this; }
- copy_tracker(T&& src) : value(std::move(src)), info(id_rvalue | id_construct | id_int), moved_from(false) {}
- copy_tracker& operator=(T&& src) { value = std::move(src); info = (id_rvalue | id_assign | id_int); moved_from = false; return *this; }
- #endif
- template<class U>
- explicit copy_tracker(const U& src) : value(src), info(id_const_lvalue | id_construct | id_int), moved_from(false) {}
- T value;
- int info;
- bool moved_from;
- };
- template<class T>
- struct value_holder
- {
- typedef copy_tracker<T> type;
- typedef copy_tracker<T> unwrapped_type;
- template<class U>
- value_holder(const U& u) : value(u) {}
- type value;
- type get() { return value; }
- const unwrapped_type& unwrap() { return value; }
- template<class U>
- const U& unwrap() { return value; }
- };
- template<class C, class P>
- struct value_holder<any<C, P> >
- {
- typedef any<C, P> type;
- typedef any<C, P> unwrapped_type;
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- template<class U>
- value_holder(U&& u) : value(std::forward<U>(u)) {}
- #else
- template<class U>
- value_holder(U& u) : value(u) {}
- template<class U>
- value_holder(const U& u) : value(u) {}
- #endif
- type value;
- type get() { return value; }
- const unwrapped_type& unwrap() { return value; }
- template<class U>
- const U& unwrap() { return any_cast<const U&>(value); }
- };
- template<class T>
- struct value_holder<T&>
- {
- typedef typename value_holder<T>::type& type;
- typedef typename value_holder<T>::unwrapped_type unwrapped_type;
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- template<class U>
- value_holder(U&& u) : impl(std::forward<U>(u)) {}
- #else
- template<class U>
- value_holder(U& u) : impl(u) {}
- template<class U>
- value_holder(const U& u) : impl(u) {}
- #endif
- value_holder<T> impl;
- type get() { return impl.value; }
- const unwrapped_type& unwrap() { return unwrap<unwrapped_type>(); }
- template<class U>
- const U& unwrap() { return impl.template unwrap<unwrapped_type>(); }
- };
- template<class T>
- struct value_holder<const T&>
- {
- typedef const typename value_holder<T>::type& type;
- typedef typename value_holder<T>::unwrapped_type unwrapped_type;
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- template<class U>
- value_holder(U&& u) : impl(std::forward<U>(u)) {}
- #else
- template<class U>
- value_holder(U& u) : impl(u) {}
- template<class U>
- value_holder(const U& u) : impl(u) {}
- #endif
- value_holder<T> impl;
- type get() { return impl.value; }
- const unwrapped_type& unwrap() { return unwrap<unwrapped_type>(); }
- template<class U>
- const U& unwrap() { return impl.template unwrap<unwrapped_type>(); }
- };
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- template<class T>
- struct value_holder<T&&>
- {
- typedef typename value_holder<T>::type&& type;
- typedef typename value_holder<T>::unwrapped_type unwrapped_type;
- template<class U>
- value_holder(U&& u) : impl(std::forward<U>(u)) {}
- value_holder<T> impl;
- type get() { return std::move(impl.value); }
- const unwrapped_type& unwrap() { return unwrap<unwrapped_type>(); }
- template<class U>
- const U& unwrap() { return impl.template unwrap<unwrapped_type>(); }
- };
- #endif
- template<class T, class A>
- struct value_holder<T(A)>
- {
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- template<class U>
- value_holder(U&& u) : init(std::forward<U>(u)), impl(init.get()) {}
- #else
- template<class U>
- value_holder(U& u) : init(u), impl(init.get()) {}
- template<class U>
- value_holder(const U& u) : init(u), impl(init.get()) {}
- #endif
- value_holder<A> init;
- value_holder<T> impl;
- typedef typename value_holder<T>::type type;
- typedef typename value_holder<A>::unwrapped_type unwrapped_type;
- type get() { return impl.get(); }
- const unwrapped_type& unwrap() { return unwrap<unwrapped_type>(); }
- template<class U>
- const U& unwrap() { return impl.template unwrap<unwrapped_type>(); }
- };
- #define TEST_ASSIGNMENT_I(LHS, RHS, result, ptr_op, R) \
- try \
- { \
- value_holder<LHS> lhs(17); \
- value_holder<RHS> rhs(23); \
- const void * original = any_cast<const void*>(&lhs.get()); \
- lhs.get() = rhs.get(); \
- typedef value_holder<R>::unwrapped_type expected_type; \
- if(const expected_type* ptr = \
- any_cast<const expected_type*>(&lhs.get())) \
- { \
- BOOST_TEST(ptr->value == 23); \
- BOOST_TEST(ptr->info == (result)); \
- BOOST_TEST(ptr ptr_op original); \
- } \
- else \
- { \
- BOOST_ERROR("Wrong type: Expected " \
- << boost::core::demangle(typeid(expected_type).name()) \
- << " but got " \
- << boost::core::demangle(typeid_of(lhs.get()).name())); \
- } \
- } \
- catch(bad_function_call&) \
- { \
- BOOST_ERROR("bad_function_call in " \
- << demangle(typeid(value_holder<LHS>::type).name()) \
- << " = " \
- << demangle(typeid(value_holder<RHS>::type).name())); \
- }
- #define TEST_ASSIGNMENT_id_dispatch(LHS, RHS, result) \
- TEST_ASSIGNMENT_I(LHS, RHS, result, ==, LHS)
- #define TEST_ASSIGNMENT_id_fallback(LHS, RHS, result) \
- TEST_ASSIGNMENT_I(LHS, RHS, result, !=, RHS)
- #define TEST_ASSIGNMENT_id_throw(LHS, RHS, result) \
- { \
- value_holder<LHS> lhs(17); \
- value_holder<RHS> rhs(23); \
- BOOST_CHECK_THROW(lhs.get() = rhs.get(), bad_function_call); \
- }
- #define TEST_ASSIGNMENT(LHS, RHS, tag, result) \
- BOOST_PP_CAT(TEST_ASSIGNMENT_, tag)(LHS, RHS, result)
- BOOST_AUTO_TEST_CASE(test_nothing)
- {
- // Nothing to test. Assignment is entirely illegal
- }
- BOOST_AUTO_TEST_CASE(test_nothing_relaxed)
- {
- typedef ::boost::mpl::vector<
- destructible<>,
- typeid_<>,
- constructible<_self(int)>,
- relaxed
- > test_concept;
- typedef test_class<int, false, false, false, false> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- // Compile-time check.
- binding<test_concept> test_binding = make_binding< ::boost::mpl::map< ::boost::mpl::pair<_self, test_type> > >();
- any_val v1(test_binding, 1);
- // assignment of same type
- // different stored type
- // raw value
- // assignment to a reference
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(int), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(int&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(int&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(int&), id_fallback, id_const_lvalue | id_construct | id_int);
- // reference with a different type
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- // reference with raw value
- TEST_ASSIGNMENT(any_ref&(int&), int&, id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), long&, id_fallback, id_const_lvalue | id_construct | id_int);
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- typedef any<test_concept, _self&&> any_rref;
- // rvalue reference as the rhs
- // assignment to an rvalue reference
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&&(int), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(int&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(int&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(int&&), id_fallback, id_const_lvalue | id_construct | id_int);
- // rvalue reference with a different type
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&&(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- // rvalue reference with raw value
- TEST_ASSIGNMENT(any_rref&(int&&), int&&, id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), long&&, id_fallback, id_const_lvalue | id_construct | id_int);
- #endif
- }
- BOOST_AUTO_TEST_CASE(test_copy_assignable)
- {
- typedef ::boost::mpl::vector<
- destructible<>,
- typeid_<>,
- assignable<>,
- constructible<_self(int)>
- > test_concept;
- typedef test_class<int, false, false, true, false> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- typedef any<test_concept, const _self&> any_cref;
- // Compile-time check.
- binding<test_concept> test_binding = make_binding< ::boost::mpl::map< ::boost::mpl::pair<_self, test_type> > >();
- any_val v1(test_binding, 1);
- // assignment of same type
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- TEST_ASSIGNMENT(any_val&(int), any_val&&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- #endif
- TEST_ASSIGNMENT(any_val&(int), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // different stored type (undefined behavior)
- // raw value (compile error)
- // assignment to a reference
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- TEST_ASSIGNMENT(any_ref&(int&), any_val&&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- #endif
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // reference with a different type (undefined behavior)
- // reference with raw value (compile error)
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- typedef any<test_concept, _self&&> any_rref;
- // rvalue reference as the rhs
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref const&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // rvalue reference with a different type (undefined behavior)
- // rvalue reference with raw value (compile error)
- #endif
- }
- BOOST_AUTO_TEST_CASE(test_copy_assignable_relaxed)
- {
- typedef ::boost::mpl::vector<
- destructible<>,
- typeid_<>,
- assignable<>,
- constructible<_self(int)>,
- relaxed
- > test_concept;
- typedef test_class<int, false, false, true, false> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- typedef any<test_concept, const _self&> any_cref;
- // Compile-time check.
- binding<test_concept> test_binding = make_binding< ::boost::mpl::map< ::boost::mpl::pair<_self, test_type> > >();
- any_val v1(test_binding, 1);
- // assignment of same type
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- TEST_ASSIGNMENT(any_val&(int), any_val&&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- #endif
- TEST_ASSIGNMENT(any_val&(int), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // different stored type
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- TEST_ASSIGNMENT(any_val&(int), any_val&&(long), id_throw, 0);
- #endif
- TEST_ASSIGNMENT(any_val&(int), any_val&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_ref(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_cref(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(long&), id_throw, 0);
- // raw value
- TEST_ASSIGNMENT(any_val&(int), int, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int&, id_fallback, id_maybe_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long&, id_fallback, id_maybe_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- // assignment to a reference
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- TEST_ASSIGNMENT(any_ref&(int&), any_val&&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- #endif
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // reference with a different type
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- TEST_ASSIGNMENT(any_ref&(int&), any_val&&(long), id_throw, 0);
- #endif
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val const&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref const&(long&), id_throw, 0);
- // reference with raw value
- TEST_ASSIGNMENT(any_ref&(int&), int&, id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), long&, id_fallback, id_const_lvalue | id_construct | id_int);
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- typedef any<test_concept, _self&&> any_rref;
- // rvalue reference as the rhs
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(long&&), id_throw, );
- TEST_ASSIGNMENT(any_ref&(int&), any_rref(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref const&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref&(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref const&(long&&), id_throw, 0);
- // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // rvalue reference with a different type
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&&(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val const&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref const&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref const&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- // rvalue reference with raw value
- TEST_ASSIGNMENT(any_rref&(int&&), int&&, id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), long&&, id_fallback, id_const_lvalue | id_construct | id_int);
- #endif
- }
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- BOOST_AUTO_TEST_CASE(test_move_assignable)
- {
- typedef ::boost::mpl::vector<
- destructible<>,
- typeid_<>,
- move_assignable<>,
- constructible<_self(int)>
- > test_concept;
- typedef test_class<int, false, false, false, true> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- // Compile-time check.
- binding<test_concept> test_binding = make_binding< ::boost::mpl::map< ::boost::mpl::pair<_self, test_type> > >();
- any_val v1(test_binding, 1);
- // assignment of same type
- TEST_ASSIGNMENT(any_val&(int), any_val&&(int), id_dispatch, id_rvalue | id_assign | id_copy);
- // different stored type
- // raw value
- // assignment to a reference
- TEST_ASSIGNMENT(any_ref&(int&), any_val&&(int), id_dispatch, id_rvalue | id_assign | id_copy);
- // reference with a different type
- // reference with raw value
- typedef any<test_concept, _self&&> any_rref;
- // rvalue reference as the rhs
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);;
- // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&&(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- // rvalue reference with a different type
- // rvalue reference with raw value
- }
- BOOST_AUTO_TEST_CASE(test_move_assignable_relaxed)
- {
- typedef ::boost::mpl::vector<
- destructible<>,
- typeid_<>,
- move_assignable<>,
- constructible<_self(int)>,
- relaxed
- > test_concept;
- typedef test_class<int, false, false, false, true> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- // Compile-time check.
- binding<test_concept> test_binding = make_binding< ::boost::mpl::map< ::boost::mpl::pair<_self, test_type> > >();
- any_val v1(test_binding, 1);
- // assignment of same type
- TEST_ASSIGNMENT(any_val&(int), any_val&&(int), id_dispatch, id_rvalue | id_assign | id_copy);
- // different stored type
- TEST_ASSIGNMENT(any_val&(int), any_val&&(long), id_throw, 0);
- // raw value
- // assignment to a reference
- TEST_ASSIGNMENT(any_ref&(int&), any_val&&(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(int), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(int&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(int&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(int&), id_fallback, id_const_lvalue | id_construct | id_int);
- // reference with a different type
- TEST_ASSIGNMENT(any_ref&(int&), any_val&&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- // reference with raw value
- TEST_ASSIGNMENT(any_ref&(int&), int&, id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), long&, id_fallback, id_const_lvalue | id_construct | id_int);
- typedef any<test_concept, _self&&> any_rref;
- // rvalue reference as the rhs
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref&(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref const&(long&&), id_throw, 0);
- // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&&(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- // rvalue reference with a different type
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&&(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- // rvalue reference with raw value
- TEST_ASSIGNMENT(any_rref&(int&&), int&&, id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), long&&, id_fallback, id_const_lvalue | id_construct | id_int);
- }
- #ifndef BOOST_NO_CXX11_REF_QUALIFIERS
- BOOST_AUTO_TEST_CASE(test_move_and_copy_assignable)
- {
- typedef ::boost::mpl::vector<
- destructible<>,
- typeid_<>,
- assignable<>,
- move_assignable<>,
- constructible<_self(int)>
- > test_concept;
- typedef test_class<int, false, false, true, true> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- typedef any<test_concept, const _self&> any_cref;
- // Compile-time check.
- binding<test_concept> test_binding = make_binding< ::boost::mpl::map< ::boost::mpl::pair<_self, test_type> > >();
- any_val v1(test_binding, 1);
- // assignment of same type
- TEST_ASSIGNMENT(any_val&(int), any_val&&(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // different stored type (undefined behavior)
- // raw value (compile error)
- // assignment to a reference
- TEST_ASSIGNMENT(any_ref&(int&), any_val&&(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // reference with a different type (undefined behavior)
- // reference with raw value (compile error)
- typedef any<test_concept, _self&&> any_rref;
- // rvalue reference as the rhs
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&&(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- // rvalue reference with a different type (undefined behavior)
- // rvalue reference with raw value (compile error)
- }
- BOOST_AUTO_TEST_CASE(test_move_and_copy_assignable_relaxed)
- {
- typedef ::boost::mpl::vector<
- destructible<>,
- typeid_<>,
- assignable<>,
- move_assignable<>,
- constructible<_self(int)>,
- relaxed
- > test_concept;
- typedef test_class<int, false, false, true, true> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- typedef any<test_concept, const _self&> any_cref;
- // Compile-time check.
- binding<test_concept> test_binding = make_binding< ::boost::mpl::map< ::boost::mpl::pair<_self, test_type> > >();
- any_val v1(test_binding, 1);
- // assignment of same type
- TEST_ASSIGNMENT(any_val&(int), any_val&&(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // different stored type
- TEST_ASSIGNMENT(any_val&(int), any_val&&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_val&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_ref(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_cref(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(long&), id_throw, 0);
- // raw value
- TEST_ASSIGNMENT(any_val&(int), int, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- // assignment to a reference
- TEST_ASSIGNMENT(any_ref&(int&), any_val&&(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // reference with a different type
- TEST_ASSIGNMENT(any_ref&(int&), any_val&&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val const&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref const&(long&), id_throw, 0);
- // reference with raw value
- TEST_ASSIGNMENT(any_ref&(int&), int&, id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), long&, id_fallback, id_const_lvalue | id_construct | id_int);
- typedef any<test_concept, _self&&> any_rref;
- // rvalue reference as the rhs
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref&(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref const&(long&&), id_throw, 0);
- // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&&(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- // rvalue reference with a different type
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&&(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val const&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref const&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref const&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- // rvalue reference with raw value
- TEST_ASSIGNMENT(any_rref&(int&&), int&&, id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), long&&, id_fallback, id_const_lvalue | id_construct | id_int);
- }
- #endif // BOOST_NO_CXX11_REF_QUALIFIERS
- #endif // BOOST_NO_CXX11_RVALUE_REFERENCES
- BOOST_AUTO_TEST_CASE(test_copy_constructible_only)
- {
- // Nothing to test. Assignment is entirely illegal
- }
- BOOST_AUTO_TEST_CASE(test_copy_constructible_only_relaxed)
- {
- typedef ::boost::mpl::vector<
- common<>,
- relaxed
- > test_concept;
- typedef test_class<int, true, false, false, false> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- typedef any<test_concept, const _self&> any_cref;
- // Compile-time check.
- TEST_ASSIGNMENT(any_val&(int), test_type&, id_fallback, id_maybe_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), test_type const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- // assignment of same type
- TEST_ASSIGNMENT(any_val&(int), any_val(int), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(int), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(int), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- // different stored type
- TEST_ASSIGNMENT(any_val&(int), any_val(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- // raw value
- TEST_ASSIGNMENT(any_val&(int), int, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int&, id_fallback, id_maybe_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long&, id_fallback, id_maybe_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- // assignment to a reference
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(int), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(int&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(int&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(int&), id_fallback, id_const_lvalue | id_construct | id_int);
- // reference with a different type
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- // reference with raw value
- TEST_ASSIGNMENT(any_ref&(int&), int&, id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), long&, id_fallback, id_const_lvalue | id_construct | id_int);
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- typedef any<test_concept, _self&&> any_rref;
- // rvalue reference as the rhs
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref(long&&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(long&&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(long&&), id_fallback, id_const_lvalue | id_construct | id_copy);
- // assignment to an rvalue reference
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&&(int), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(int&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(int&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(int&&), id_fallback, id_const_lvalue | id_construct | id_int);
- // rvalue reference with a different type
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&&(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- // rvalue reference with raw value
- TEST_ASSIGNMENT(any_rref&(int&&), int&&, id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), long&&, id_fallback, id_const_lvalue | id_construct | id_int);
- #endif
- }
- BOOST_AUTO_TEST_CASE(test_copy)
- {
- typedef ::boost::mpl::vector<
- common<>,
- assignable<>
- > test_concept;
- typedef test_class<int, true, false, true, false> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- typedef any<test_concept, const _self&> any_cref;
- // Compile-time check.
- TEST_ASSIGNMENT(any_val&(test_type&), any_val&(test_type&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(test_type&), any_val&(const test_type&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // assignment of same type
- TEST_ASSIGNMENT(any_val&(int), any_val(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // different stored type (undefined behavior)
- // raw value (compile error)
- // assignment to a reference
- TEST_ASSIGNMENT(any_ref&(int&), any_val(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // reference with a different type (undefined behavior)
- // reference with raw value (compile error)
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- typedef any<test_concept, _self&&> any_rref;
- // rvalue reference as the rhs
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref const&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
- TEST_ASSIGNMENT(any_rref&(int&&), any_val(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // rvalue reference with a different type (undefined behavior)
- // rvalue reference with raw value (compile error)
- #endif
- }
- BOOST_AUTO_TEST_CASE(test_copy_relaxed)
- {
- typedef ::boost::mpl::vector<
- common<>,
- assignable<>,
- relaxed
- > test_concept;
- typedef test_class<int, true, false, true, false> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- typedef any<test_concept, const _self&> any_cref;
- // Compile-time check.
- TEST_ASSIGNMENT(any_val&(int), test_type&, id_fallback, id_maybe_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), test_type const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- // assignment of same type
- TEST_ASSIGNMENT(any_val&(int), any_val(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // different stored type
- TEST_ASSIGNMENT(any_val&(int), any_val(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- // raw value
- TEST_ASSIGNMENT(any_val&(int), int, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int&, id_fallback, id_maybe_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long&, id_fallback, id_maybe_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- // assignment to a reference
- TEST_ASSIGNMENT(any_ref&(int&), any_val(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // reference with a different type
- TEST_ASSIGNMENT(any_ref&(int&), any_val(long), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val const&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref const&(long&), id_throw, 0);
- // reference with raw value
- TEST_ASSIGNMENT(any_ref&(int&), int&, id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), long&, id_fallback, id_const_lvalue | id_construct | id_int);
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- typedef any<test_concept, _self&&> any_rref;
- // rvalue reference as the rhs
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref(long&&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(long&&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(long&&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref const&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref&(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref const&(long&&), id_throw, 0);
- // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
- TEST_ASSIGNMENT(any_rref&(int&&), any_val(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // rvalue reference with a different type
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&&(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val const&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref const&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref const&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- // rvalue reference with raw value
- TEST_ASSIGNMENT(any_rref&(int&&), int&&, id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), long&&, id_fallback, id_const_lvalue | id_construct | id_int);
- #endif
- }
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- BOOST_AUTO_TEST_CASE(test_copy_constructable_move_assignable)
- {
- typedef ::boost::mpl::vector<
- common<>,
- move_assignable<>
- > test_concept;
- typedef test_class<int, true, false, false, true> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- // Compile-time check.
- TEST_ASSIGNMENT(any_val&(test_type&), any_val(test_type&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(test_type&), any_val(test_type const&), id_dispatch, id_rvalue | id_assign | id_copy);
- // assignment of same type
- TEST_ASSIGNMENT(any_val&(int), any_val(int), id_dispatch, id_rvalue | id_assign | id_copy);
- // different stored type
- // raw value
- // assignment to a reference
- TEST_ASSIGNMENT(any_ref&(int&), any_val(int), id_dispatch, id_rvalue | id_assign | id_copy);
- // reference with a different type
- // reference with raw value
- typedef any<test_concept, _self&&> any_rref;
- // rvalue reference as the rhs
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);;
- // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
- TEST_ASSIGNMENT(any_rref&(int&&), any_val(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- // rvalue reference with a different type
- // rvalue reference with raw value
- }
- BOOST_AUTO_TEST_CASE(test_copy_constructable_move_assignable_relaxed)
- {
- typedef ::boost::mpl::vector<
- common<>,
- move_assignable<>,
- relaxed
- > test_concept;
- typedef test_class<int, true, false, false, true> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- typedef any<test_concept, const _self&> any_cref;
- // Compile-time check.
- TEST_ASSIGNMENT(any_val&(int), test_type&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), test_type const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- // assignment of same type
- TEST_ASSIGNMENT(any_val&(int), any_val(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(int), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(int), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- // different stored type
- TEST_ASSIGNMENT(any_val&(int), any_val(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- // raw value
- TEST_ASSIGNMENT(any_val&(int), int, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- // assignment to a reference
- TEST_ASSIGNMENT(any_ref&(int&), any_val(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(int), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(int&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(int&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(int&), id_fallback, id_const_lvalue | id_construct | id_int);
- // reference with a different type
- TEST_ASSIGNMENT(any_ref&(int&), any_val(long), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- // reference with raw value
- TEST_ASSIGNMENT(any_ref&(int&), int&, id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), long&, id_fallback, id_const_lvalue | id_construct | id_int);
- typedef any<test_concept, _self&&> any_rref;
- // rvalue reference as the rhs
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref(long&&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(long&&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(long&&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref&(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref const&(long&&), id_throw, 0);
- // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
- TEST_ASSIGNMENT(any_rref&(int&&), any_val(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- // rvalue reference with a different type
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&&(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- // rvalue reference with raw value
- TEST_ASSIGNMENT(any_rref&(int&&), int&&, id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), long&&, id_fallback, id_const_lvalue | id_construct | id_int);
- }
- #ifndef BOOST_NO_CXX11_REF_QUALIFIERS
- BOOST_AUTO_TEST_CASE(test_copy_constructible_move_and_copy_assignable)
- {
- typedef ::boost::mpl::vector<
- common<>,
- assignable<>,
- move_assignable<>
- > test_concept;
- typedef test_class<int, true, false, true, true> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- typedef any<test_concept, const _self&> any_cref;
- // Compile-time check.
- TEST_ASSIGNMENT(any_val&(test_type&), any_val&(test_type&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(test_type&), any_val&(const test_type&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // assignment of same type
- TEST_ASSIGNMENT(any_val&(int), any_val(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // different stored type (undefined behavior)
- // raw value (compile error)
- // assignment to a reference
- TEST_ASSIGNMENT(any_ref&(int&), any_val(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // reference with a different type (undefined behavior)
- // reference with raw value (compile error)
- typedef any<test_concept, _self&&> any_rref;
- // rvalue reference as the rhs
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
- TEST_ASSIGNMENT(any_rref&(int&&), any_val(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- // rvalue reference with a different type (undefined behavior)
- // rvalue reference with raw value (compile error)
- }
- BOOST_AUTO_TEST_CASE(test_copy_constructible_move_and_copy_assignable_relaxed)
- {
- typedef ::boost::mpl::vector<
- common<>,
- assignable<>,
- move_assignable<>,
- relaxed
- > test_concept;
- typedef test_class<int, true, false, true, true> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- typedef any<test_concept, const _self&> any_cref;
- // Compile-time check.
- TEST_ASSIGNMENT(any_val&(int), test_type&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), test_type const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- // assignment of same type
- TEST_ASSIGNMENT(any_val&(int), any_val(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // different stored type
- TEST_ASSIGNMENT(any_val&(int), any_val(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- // raw value
- TEST_ASSIGNMENT(any_val&(int), int, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- // assignment to a reference
- TEST_ASSIGNMENT(any_ref&(int&), any_val(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // reference with a different type
- TEST_ASSIGNMENT(any_ref&(int&), any_val(long), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_val&(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_val const&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref&(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_ref const&(long&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_cref const&(long&), id_throw, 0);
- // reference with raw value
- TEST_ASSIGNMENT(any_ref&(int&), int&, id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_ref&(int&), long&, id_fallback, id_const_lvalue | id_construct | id_int);
- typedef any<test_concept, _self&&> any_rref;
- // rvalue reference as the rhs
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref(long&&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(long&&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(long&&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref&(long&&), id_throw, 0);
- TEST_ASSIGNMENT(any_ref&(int&), any_rref const&(long&&), id_throw, 0);
- // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
- TEST_ASSIGNMENT(any_rref&(int&&), any_val(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- // rvalue reference with a different type
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&&(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_val const&(long), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_ref const&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_cref const&(long&), id_throw, 0);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref&(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), any_rref const&(long&&), id_fallback, id_const_lvalue | id_construct | id_int);
- // rvalue reference with raw value
- TEST_ASSIGNMENT(any_rref&(int&&), int&&, id_fallback, id_const_lvalue | id_construct | id_int);
- TEST_ASSIGNMENT(any_rref&(int&&), long&&, id_fallback, id_const_lvalue | id_construct | id_int);
- }
- #endif // BOOST_NO_CXX11_REF_QUALIFIERS
- #endif // BOOST_NO_CXX11_RVALUE_REFERENCES
- #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
- BOOST_AUTO_TEST_CASE(test_move_and_copy_constructible_only)
- {
- // Nothing to test. Assignment is entirely illegal
- }
- BOOST_AUTO_TEST_CASE(test_move_and_copy_constructible_only_relaxed)
- {
- typedef ::boost::mpl::vector<
- common<>,
- movable_common<>,
- relaxed
- > test_concept;
- typedef test_class<int, true, true, false, false> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- typedef any<test_concept, const _self&> any_cref;
- typedef any<test_concept, _self&&> any_rref;
- // Compile-time check.
- TEST_ASSIGNMENT(any_val&(int), test_type&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), test_type const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- // assignment of same type
- TEST_ASSIGNMENT(any_val&(int), any_val(int), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(int), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(int), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_fallback, id_rvalue | id_construct | id_copy);
- // different stored type
- TEST_ASSIGNMENT(any_val&(int), any_val(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref(long&&), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(long&&), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(long&&), id_fallback, id_rvalue | id_construct | id_copy);
- // raw value
- TEST_ASSIGNMENT(any_val&(int), int, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- }
- BOOST_AUTO_TEST_CASE(test_move_and_copy_constructible_copy_assignable)
- {
- typedef ::boost::mpl::vector<
- common<>,
- movable_common<>,
- assignable<>
- > test_concept;
- typedef test_class<int, true, true, true, false> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- typedef any<test_concept, const _self&> any_cref;
- typedef any<test_concept, _self&&> any_rref;
- // Compile-time check.
- TEST_ASSIGNMENT(any_val&(test_type&), any_val&(test_type&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(test_type&), any_val&(const test_type&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // assignment of same type
- TEST_ASSIGNMENT(any_val&(int), any_val(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // different stored type (undefined behavior)
- }
- BOOST_AUTO_TEST_CASE(test_move_and_copy_constructible_copy_assignable_relaxed)
- {
- typedef ::boost::mpl::vector<
- common<>,
- movable_common<>,
- assignable<>,
- relaxed
- > test_concept;
- typedef test_class<int, true, true, true, false> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- typedef any<test_concept, const _self&> any_cref;
- typedef any<test_concept, _self&&> any_rref;
- // Compile-time check.
- TEST_ASSIGNMENT(any_val&(int), test_type&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), test_type const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- // assignment of same type
- TEST_ASSIGNMENT(any_val&(int), any_val(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // different stored type
- TEST_ASSIGNMENT(any_val&(int), any_val(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref(long&&), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(long&&), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(long&&), id_fallback, id_rvalue | id_construct | id_copy);
- // raw value
- TEST_ASSIGNMENT(any_val&(int), int, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- }
- BOOST_AUTO_TEST_CASE(test_move_and_copy_constructable_move_assignable)
- {
- typedef ::boost::mpl::vector<
- common<>,
- movable_common<>,
- move_assignable<>
- > test_concept;
- typedef test_class<int, true, true, false, true> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&&> any_rref;
- // Compile-time check.
- TEST_ASSIGNMENT(any_val&(test_type&), any_val(test_type), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(test_type&), any_val(test_type&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(test_type&), any_val(test_type const&), id_dispatch, id_rvalue | id_assign | id_copy);
- // assignment of same type
- TEST_ASSIGNMENT(any_val&(int), any_val(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- // different stored type
- // raw value
- }
- BOOST_AUTO_TEST_CASE(test_move_and_copy_constructable_move_assignable_relaxed)
- {
- typedef ::boost::mpl::vector<
- common<>,
- movable_common<>,
- move_assignable<>,
- relaxed
- > test_concept;
- typedef test_class<int, true, true, false, true> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- typedef any<test_concept, const _self&> any_cref;
- typedef any<test_concept, _self&&> any_rref;
- // Compile-time check.
- TEST_ASSIGNMENT(any_val&(int), test_type, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), test_type&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), test_type const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- // assignment of same type
- TEST_ASSIGNMENT(any_val&(int), any_val(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(int), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(int), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(int&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- // different stored type
- TEST_ASSIGNMENT(any_val&(int), any_val(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref(long&&), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(long&&), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(long&&), id_fallback, id_rvalue | id_construct | id_copy);
- // raw value
- TEST_ASSIGNMENT(any_val&(int), int, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- }
- BOOST_AUTO_TEST_CASE(test_move_and_copy_constructible_move_and_copy_assignable)
- {
- typedef ::boost::mpl::vector<
- common<>,
- movable_common<>,
- assignable<>,
- move_assignable<>
- > test_concept;
- typedef test_class<int, true, true, true, true> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- typedef any<test_concept, const _self&> any_cref;
- typedef any<test_concept, _self&&> any_rref;
- // Compile-time check.
- TEST_ASSIGNMENT(any_val&(test_type&), any_val&(test_type), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(test_type&), any_val&(test_type&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(test_type&), any_val&(const test_type&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- // assignment of same type
- TEST_ASSIGNMENT(any_val&(int), any_val(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- // different stored type (undefined behavior)
- }
- BOOST_AUTO_TEST_CASE(test_move_and_copy_constructible_move_and_copy_assignable_relaxed)
- {
- typedef ::boost::mpl::vector<
- common<>,
- movable_common<>,
- assignable<>,
- move_assignable<>,
- relaxed
- > test_concept;
- typedef test_class<int, true, true, true, true> test_type;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- typedef any<test_concept, const _self&> any_cref;
- typedef any<test_concept, _self&&> any_rref;
- // Compile-time check.
- TEST_ASSIGNMENT(any_val&(int), test_type, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), test_type&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), test_type const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- // assignment of same type
- TEST_ASSIGNMENT(any_val&(int), any_val(int), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(int), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(int&), id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(int&&), id_dispatch, id_rvalue | id_assign | id_copy);
- // different stored type
- TEST_ASSIGNMENT(any_val&(int), any_val(long), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val&(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_val const&(long), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_ref const&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_cref const&(long&), id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref(long&&), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref&(long&&), id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), any_rref const&(long&&), id_fallback, id_rvalue | id_construct | id_copy);
- // raw value
- TEST_ASSIGNMENT(any_val&(int), int, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long, id_fallback, id_rvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long&, id_fallback, id_lvalue | id_construct | id_copy);
- TEST_ASSIGNMENT(any_val&(int), long const&, id_fallback, id_const_lvalue | id_construct | id_copy);
- }
- #endif // BOOST_NO_RVALUE_REFERENCES || BOOST_NO_CXX11_REF_QUALIFIERS
- BOOST_AUTO_TEST_CASE(test_basic_int)
- {
- typedef ::boost::mpl::vector<
- common<>,
- assignable<_self, copy_tracker<int> >
- > test_concept;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- TEST_ASSIGNMENT(any_val&(int), int, id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int&, id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int const&, id_dispatch, id_const_lvalue | id_assign | id_copy);
-
- TEST_ASSIGNMENT(any_ref&(int&), int, id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), int&, id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), int const&, id_dispatch, id_const_lvalue | id_assign | id_copy);
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- typedef any<test_concept, _self&&> any_rref;
- TEST_ASSIGNMENT(any_rref&(int&&), int, id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), int&, id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), int const&, id_dispatch, id_const_lvalue | id_assign | id_copy);
- #endif
- }
- BOOST_AUTO_TEST_CASE(test_basic_relaxed_int)
- {
- typedef ::boost::mpl::vector<
- common<>,
- assignable<_self, copy_tracker<int> >,
- relaxed
- > test_concept;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- TEST_ASSIGNMENT(any_val&(int), int, id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int&, id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int const&, id_dispatch, id_const_lvalue | id_assign | id_copy);
-
- TEST_ASSIGNMENT(any_ref&(int&), int, id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), int&, id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), int const&, id_dispatch, id_const_lvalue | id_assign | id_copy);
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- typedef any<test_concept, _self&&> any_rref;
- TEST_ASSIGNMENT(any_rref&(int&&), int, id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), int&, id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), int const&, id_dispatch, id_const_lvalue | id_assign | id_copy);
- #endif
- }
- BOOST_AUTO_TEST_CASE(test_relaxed_no_copy_int)
- {
- typedef ::boost::mpl::vector<
- destructible<>,
- typeid_<>,
- assignable<_self, copy_tracker<int> >,
- relaxed
- > test_concept;
- typedef any<test_concept> any_val;
- typedef any<test_concept, _self&> any_ref;
- TEST_ASSIGNMENT(any_val&(int), int, id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int&, id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_val&(int), int const&, id_dispatch, id_const_lvalue | id_assign | id_copy);
-
- TEST_ASSIGNMENT(any_ref&(int&), int, id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), int&, id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_ref&(int&), int const&, id_dispatch, id_const_lvalue | id_assign | id_copy);
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- typedef any<test_concept, _self&&> any_rref;
- TEST_ASSIGNMENT(any_rref&(int&&), int, id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), int&, id_dispatch, id_const_lvalue | id_assign | id_copy);
- TEST_ASSIGNMENT(any_rref&(int&&), int const&, id_dispatch, id_const_lvalue | id_assign | id_copy);
- #endif
- }
- BOOST_AUTO_TEST_CASE(test_relaxed_no_assign_int)
- {
- typedef ::boost::mpl::vector<
- common<>,
- relaxed
- > test_concept;
- any<test_concept> x(1);
- x = 2;
- BOOST_CHECK_EQUAL(any_cast<int>(x), 2);
- }
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- struct move_only_assign_int
- {
- explicit move_only_assign_int(int i)
- : value(i) {}
- move_only_assign_int(move_only_assign_int&& other)
- : value(other.value) { other.value = 0; }
- move_only_assign_int& operator=(move_only_assign_int&& other)
- { value = other.value; other.value = 0; return *this; }
- move_only_assign_int& operator=(int&& i)
- { value = i; return *this; }
- int value;
- private:
- move_only_assign_int(const move_only_assign_int&);
- move_only_assign_int& operator=(const move_only_assign_int&);
- };
- struct only_assign_int
- {
- explicit only_assign_int(int i)
- : value(i) {}
- only_assign_int& operator=(int&& i)
- { value = i; return *this; }
- int value;
- private:
- only_assign_int(only_assign_int&&);
- only_assign_int(const only_assign_int&);
- only_assign_int& operator=(only_assign_int&&);
- only_assign_int& operator=(const only_assign_int&);
- };
- struct move_and_copy_assign_int
- {
- explicit move_and_copy_assign_int(int i)
- : value(i) {}
- move_and_copy_assign_int& operator=(move_and_copy_assign_int&& other)
- { value = other.value; other = 0; return *this; }
- move_and_copy_assign_int& operator=(const move_and_copy_assign_int& other)
- { value = other.value; return *this; }
- move_and_copy_assign_int& operator=(int&& i)
- { value = i; return *this; }
- move_and_copy_assign_int& operator=(const int& i)
- { value = i; return *this; }
- int value;
- private:
- move_and_copy_assign_int(move_and_copy_assign_int&&);
- move_and_copy_assign_int(const move_and_copy_assign_int&);
- };
- struct move_and_copy_construct_assign_int
- {
- explicit move_and_copy_construct_assign_int(int i)
- : value(i) {}
- move_and_copy_construct_assign_int(move_and_copy_construct_assign_int&& other)
- : value(other.value) { other.value = 0; }
- move_and_copy_construct_assign_int(const move_and_copy_construct_assign_int& other)
- : value(other.value) {}
- move_and_copy_construct_assign_int& operator=(move_and_copy_construct_assign_int&& other)
- { value = other.value; other = 0; return *this; }
- move_and_copy_construct_assign_int& operator=(const move_and_copy_construct_assign_int& other)
- { value = other.value; return *this; }
- move_and_copy_construct_assign_int& operator=(int&& i)
- { value = i; return *this; }
- move_and_copy_construct_assign_int& operator=(const int& i)
- { value = i; return *this; }
- int value;
- };
- struct copy_only_assign_int
- {
- explicit copy_only_assign_int(int i)
- : value(i) {}
- copy_only_assign_int(const copy_only_assign_int& other)
- : value(other.value) {}
- copy_only_assign_int& operator=(const copy_only_assign_int& other)
- { value = other.value; return *this; }
- copy_only_assign_int& operator=(int&& i)
- { value = i; return *this; }
- copy_only_assign_int& operator=(const int& i)
- { value = i; return *this; }
- int value;
- private:
- copy_only_assign_int(copy_only_assign_int&&);
- copy_only_assign_int& operator=(copy_only_assign_int&&);
- };
- struct copy_only_assign_double
- {
- explicit copy_only_assign_double(double i)
- : value(i) {}
- copy_only_assign_double(const copy_only_assign_double& other)
- : value(other.value) {}
- copy_only_assign_double& operator=(const copy_only_assign_double& other)
- { value = other.value; return *this; }
- copy_only_assign_double& operator=(double&& i)
- { value = i; return *this; }
- copy_only_assign_double& operator=(const double& i)
- { value = i; return *this; }
- double value;
- private:
- copy_only_assign_double(copy_only_assign_double&&);
- copy_only_assign_double& operator=(copy_only_assign_double&&);
- };
- BOOST_AUTO_TEST_CASE(test_movable_basic_int)
- {
- typedef ::boost::mpl::vector<
- movable_common<>,
- move_assignable<_self, int>
- > test_concept;
- typedef move_only_assign_int test_type;
- test_type source_x(1);
- any<test_concept> x(std::move(source_x));
- test_type* ip = any_cast<test_type*>(&x);
- x = std::move(2);
- BOOST_CHECK_EQUAL(any_cast<const test_type&>(x).value, 2);
- // make sure that we're actually using assignment
- // of the underlying object, not copy and swap.
- BOOST_CHECK_EQUAL(any_cast<test_type*>(&x), ip);
- }
- BOOST_AUTO_TEST_CASE(test_movable_basic_relaxed_int)
- {
- typedef ::boost::mpl::vector<
- movable_common<>,
- move_assignable<_self, int>,
- relaxed
- > test_concept;
- typedef move_only_assign_int test_type;
- test_type source_x(1);
- any<test_concept> x(std::move(source_x));
- test_type* ip = any_cast<test_type*>(&x);
- x = std::move(2);
- BOOST_CHECK_EQUAL(any_cast<const test_type&>(x).value, 2);
- // make sure that we're actually using assignment
- // of the underlying object, not copy and swap.
- BOOST_CHECK_EQUAL(any_cast<test_type*>(&x), ip);
- }
- BOOST_AUTO_TEST_CASE(test_relaxed_no_constructible_int)
- {
- typedef ::boost::mpl::vector<
- destructible<>,
- typeid_<>,
- constructible<_self(int)>,
- move_assignable<_self, int>,
- relaxed
- > test_concept;
- typedef only_assign_int test_type;
- typedef ::boost::mpl::map< ::boost::mpl::pair<_self, test_type> > type;
- any<test_concept> x(binding<test_concept>(make_binding<type>()), 1);
- BOOST_CHECK_EQUAL(any_cast<const test_type&>(x).value, 1);
- test_type* ip = any_cast<test_type*>(&x);
- x = std::move(2);
- BOOST_CHECK_EQUAL(any_cast<const test_type&>(x).value, 2);
- // make sure that we're actually using assignment
- // of the underlying object, not copy and swap.
- BOOST_CHECK_EQUAL(any_cast<test_type*>(&x), ip);
- }
- BOOST_AUTO_TEST_CASE(test_movable_relaxed_no_assign_int)
- {
- typedef ::boost::mpl::vector<
- movable_common<>,
- relaxed
- > test_concept;
- typedef move_only_assign_int test_type;
- test_type source_x(1);
- any<test_concept> x(std::move(source_x));
- x = test_type(2);
- BOOST_CHECK_EQUAL(any_cast<const test_type&>(x).value, 2);
- }
- #ifndef BOOST_NO_CXX11_REF_QUALIFIERS
- BOOST_AUTO_TEST_CASE(test_move_and_copy_assignable_int)
- {
- typedef ::boost::mpl::vector<
- destructible<>,
- typeid_<>,
- constructible<_self(int)>,
- assignable<_self, _self>,
- move_assignable<_self, _self>,
- assignable<_self, int>,
- move_assignable<_self, int>,
- relaxed
- > test_concept;
- typedef move_and_copy_assign_int test_type;
- typedef ::boost::mpl::map< ::boost::mpl::pair<_self, test_type> > type;
- any<test_concept> x(binding<test_concept>(make_binding<type>()), 1);
- BOOST_CHECK_EQUAL(any_cast<const test_type&>(x).value, 1);
- any<test_concept> y(binding<test_concept>(make_binding<type>()), 2);
- x = y;
- BOOST_CHECK_EQUAL(any_cast<const test_type&>(x).value, 2);
- any<test_concept> z(binding<test_concept>(make_binding<type>()), 3);
- x = std::move(z);
- BOOST_CHECK_EQUAL(any_cast<const test_type&>(x).value, 3);
- x = 4;
- BOOST_CHECK_EQUAL(any_cast<const test_type&>(x).value, 4);
- x = std::move(5);
- BOOST_CHECK_EQUAL(any_cast<const test_type&>(x).value, 5);
- }
- BOOST_AUTO_TEST_CASE(test_move_and_copy_assignable_copy_construct_int)
- {
- typedef ::boost::mpl::vector<
- common<>,
- assignable<_self, _self>,
- move_assignable<_self, _self>,
- assignable<_self, int>,
- move_assignable<_self, int>,
- relaxed
- > test_concept;
- typedef move_and_copy_construct_assign_int test_type;
- test_type source_x(1);
- test_type source_y(2);
- test_type source_z(3);
- any<test_concept> x(source_x);
- BOOST_CHECK_EQUAL(any_cast<const test_type&>(x).value, 1);
- test_type* ip = any_cast<test_type*>(&x);
- any<test_concept> y(source_y);
- x = y;
- BOOST_CHECK_EQUAL(any_cast<const test_type&>(x).value, 2);
- // make sure that we're actually using assignment
- // of the underlying object, not copy and swap.
- BOOST_CHECK_EQUAL(any_cast<test_type*>(&x), ip);
- any<test_concept> z(source_z);
- x = std::move(z);
- BOOST_CHECK_EQUAL(any_cast<const test_type&>(x).value, 3);
- // make sure that we're actually using move-assignment
- // of the underlying object, not copy and swap.
- BOOST_CHECK_EQUAL(any_cast<test_type*>(&x), ip);
- x = 4;
- BOOST_CHECK_EQUAL(any_cast<const test_type&>(x).value, 4);
- // make sure that we're actually using assignment
- // of the underlying object, not copy and swap.
- BOOST_CHECK_EQUAL(any_cast<test_type*>(&x), ip);
- x = std::move(5);
- BOOST_CHECK_EQUAL(any_cast<const test_type&>(x).value, 5);
- // make sure that we're actually using move-assignment
- // of the underlying object, not copy and swap.
- BOOST_CHECK_EQUAL(any_cast<test_type*>(&x), ip);
- }
- #endif // BOOST_NO_CXX11_REF_QUALIFIERS
- BOOST_AUTO_TEST_CASE(test_assignable_with_conversion)
- {
- typedef ::boost::mpl::vector<
- destructible<>,
- typeid_<>,
- assignable<_self, int>,
- relaxed
- > test_concept;
- typedef move_and_copy_construct_assign_int test_type1;
- typedef copy_only_assign_int test_type2;
- typedef copy_only_assign_double test_type3;
- test_type1 source_x(1);
- any<test_concept> x(source_x);
- BOOST_CHECK_EQUAL(any_cast<const test_type1&>(x).value, 1);
- // assigning raw values is supported because "relaxed" is in concept.
- test_type2 source_y(2);
- x = source_y;
- BOOST_CHECK_EQUAL(any_cast<const test_type2&>(x).value, 2);
- // move-assigning raw values is supported because "relaxed" is in concept.
- x = test_type1(3);
- BOOST_CHECK_EQUAL(any_cast<const test_type1&>(x).value, 3);
- // assigning int is supported because appropriate "assignable" is in concept.
- int int4 = 4;
- x = int4;
- BOOST_CHECK_EQUAL(any_cast<const test_type1&>(x).value, 4);
- int int5 = 5;
- x = std::move(int5);
- BOOST_CHECK_EQUAL(any_cast<const test_type1&>(x).value, 5);
- // assigning double (which is implicitly convertible to int) is supported
- // because appropriate "assignable" is in concept.
- double double6 = 6.5;
- x = double6; // truncates value
- BOOST_CHECK_EQUAL(any_cast<const test_type1&>(x).value, 6);
- double double7 = 7.5;
- x = std::move(double7); // truncates value
- BOOST_CHECK_EQUAL(any_cast<const test_type1&>(x).value, 7);
- // assigning raw values is supported because "relaxed" is in concept.
- test_type3 source_z(8.5);
- x = source_z;
- BOOST_CHECK_EQUAL(any_cast<const test_type3&>(x).value, 8.5);
- // assigning double (which is implicitly convertible to int) is supported
- // because appropriate "assignable" is in concept.
- double double9 = 9.5;
- x = double9; // truncates value
- BOOST_CHECK_EQUAL(any_cast<const test_type3&>(x).value, 9.0);
- double double10 = 10.5;
- x = std::move(double10); // truncates value
- BOOST_CHECK_EQUAL(any_cast<const test_type3&>(x).value, 10.0);
- }
- BOOST_AUTO_TEST_CASE(test_move_assignable_with_conversion)
- {
- typedef ::boost::mpl::vector<
- destructible<>,
- typeid_<>,
- move_assignable<_self, int>,
- relaxed
- > test_concept;
- typedef move_and_copy_construct_assign_int test_type1;
- typedef copy_only_assign_int test_type2;
- typedef copy_only_assign_double test_type3;
- test_type1 source_x(1);
- any<test_concept> x(source_x);
- BOOST_CHECK_EQUAL(any_cast<const test_type1&>(x).value, 1);
- // assigning raw values is supported because "relaxed" is in concept.
- test_type2 source_y(2);
- x = source_y;
- BOOST_CHECK_EQUAL(any_cast<const test_type2&>(x).value, 2);
- // move-assigning raw values is supported because "relaxed" is in concept.
- x = test_type1(3);
- BOOST_CHECK_EQUAL(any_cast<const test_type1&>(x).value, 3);
- // move-assigning int is supported because appropriate "move_assignable" is in concept.
- int int4 = 4;
- x = std::move(int4);
- BOOST_CHECK_EQUAL(any_cast<const test_type1&>(x).value, 4);
- // copy-assigning int is assigning a raw_value.
- int int5 = 5;
- x = int5;
- BOOST_CHECK_EQUAL(any_cast<const int&>(x), 5);
- x = source_x; // reset.
- // move-assigning double (which is implicitly convertible to int) is supported
- // because appropriate "move_assignable" is in concept.
- double double6 = 6.5;
- x = std::move(double6); // truncates value
- BOOST_CHECK_EQUAL(any_cast<const test_type1&>(x).value, 6);
- // assigning raw values is supported because "relaxed" is in concept.
- test_type3 source_z(8.5);
- x = source_z;
- BOOST_CHECK_EQUAL(any_cast<const test_type3&>(x).value, 8.5);
- // move-assigning double (which is implicitly convertible to int) is supported
- // because appropriate "move_assignable" is in concept.
- double double9 = 9.5;
- x = std::move(double9); // truncates value
- BOOST_CHECK_EQUAL(any_cast<const test_type3&>(x).value, 9.0);
- }
- #endif
|