1 // Boost.TypeErasure library
3 // Copyright 2011 Steven Watanabe
5 // Distributed under the Boost Software License Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
11 #include <boost/config.hpp>
14 #pragma warning(disable:4244) // conversion from double to int
17 #include <boost/type_erasure/any.hpp>
18 #include <boost/type_erasure/tuple.hpp>
19 #include <boost/type_erasure/builtin.hpp>
20 #include <boost/type_erasure/operators.hpp>
21 #include <boost/type_erasure/any_cast.hpp>
22 #include <boost/type_erasure/relaxed.hpp>
23 #include <boost/mpl/vector.hpp>
25 #define BOOST_TEST_MAIN
26 #include <boost/test/unit_test.hpp>
28 using namespace boost::type_erasure
;
29 using boost::core::demangle
;
31 template<class T
= _self
>
32 struct common
: ::boost::mpl::vector
<
33 copy_constructible
<T
>,
37 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
39 template<class T
= _self
>
40 struct movable_common
: ::boost::mpl::vector
<
42 constructible
<T(T
&&)>,
46 template<class T
= _self
, class U
= T
>
47 struct move_assignable
: ::boost::mpl::vector
<
53 template<class T
, bool CCtor
, bool MoveCtor
, bool CAssign
, bool MoveAssign
>
56 explicit test_class(T n
) : value(n
) {}
57 test_class(const test_class
& src
) : value(src
.value
)
59 BOOST_STATIC_ASSERT_MSG(CCtor
, "Copy constructor not allowed.");
61 test_class
& operator=(const test_class
& src
)
63 BOOST_STATIC_ASSERT_MSG(CAssign
, "Copy assignment not allowed.");
67 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
68 test_class(test_class
&& src
) : value(src
.value
)
70 BOOST_STATIC_ASSERT_MSG(MoveCtor
, "Move constructor not allowed.");
73 test_class
& operator=(test_class
&& src
)
75 BOOST_STATIC_ASSERT_MSG(MoveAssign
, "Move assignment not allowed.");
81 bool operator==(T n
) const { return value
== n
; }
85 template<class T
, bool CCtor
, bool MoveCtor
, bool CAssign
, bool MoveAssign
>
86 std::ostream
& operator<<(std::ostream
& os
, const test_class
<T
, CCtor
, MoveCtor
, CAssign
, MoveAssign
>& t
)
94 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
96 id_maybe_const_lvalue
= id_lvalue
, // used for the id of construction from a raw value
98 id_rvalue
= id_const_lvalue
,
99 id_maybe_const_lvalue
= id_const_lvalue
,
108 #pragma warning(disable:4521) // multiple copy constructors specified
109 #pragma warning(disable:4522) // multiple assignment operators specified
115 copy_tracker(const copy_tracker
& src
) : value(src
.value
), info(id_const_lvalue
| id_construct
| id_copy
), moved_from(false) {}
116 copy_tracker(copy_tracker
& src
) : value(src
.value
), info(id_lvalue
| id_construct
| id_copy
), moved_from(false) {}
117 copy_tracker
& operator=(const copy_tracker
& src
) { value
= (src
.value
); info
= (id_const_lvalue
| id_assign
| id_copy
); moved_from
= false; return *this; }
118 copy_tracker
& operator=(copy_tracker
& src
) { value
= (src
.value
); info
= (id_lvalue
| id_assign
| id_copy
); moved_from
= false; return *this; }
119 copy_tracker(const T
& src
) : value(src
), info(id_const_lvalue
| id_construct
| id_int
), moved_from(false) {}
120 copy_tracker(T
& src
) : value(src
), info(id_lvalue
| id_construct
| id_int
), moved_from(false) {}
121 copy_tracker
& operator=(const T
& src
) { value
= (src
); info
= (id_const_lvalue
| id_assign
| id_int
); moved_from
= false; return *this; }
122 copy_tracker
& operator=(T
& src
) { value
= (src
); info
= (id_lvalue
| id_assign
| id_int
); moved_from
= false; return *this; }
123 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
124 copy_tracker(copy_tracker
&& src
) : value(std::move(src
.value
)), info(id_rvalue
| id_construct
| id_copy
), moved_from(false) { src
.moved_from
= true; }
125 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; }
126 copy_tracker(T
&& src
) : value(std::move(src
)), info(id_rvalue
| id_construct
| id_int
), moved_from(false) {}
127 copy_tracker
& operator=(T
&& src
) { value
= std::move(src
); info
= (id_rvalue
| id_assign
| id_int
); moved_from
= false; return *this; }
130 explicit copy_tracker(const U
& src
) : value(src
), info(id_const_lvalue
| id_construct
| id_int
), moved_from(false) {}
139 typedef copy_tracker
<T
> type
;
140 typedef copy_tracker
<T
> unwrapped_type
;
142 value_holder(const U
& u
) : value(u
) {}
144 type
get() { return value
; }
145 const unwrapped_type
& unwrap() { return value
; }
147 const U
& unwrap() { return value
; }
150 template<class C
, class P
>
151 struct value_holder
<any
<C
, P
> >
153 typedef any
<C
, P
> type
;
154 typedef any
<C
, P
> unwrapped_type
;
155 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
157 value_holder(U
&& u
) : value(std::forward
<U
>(u
)) {}
160 value_holder(U
& u
) : value(u
) {}
162 value_holder(const U
& u
) : value(u
) {}
165 type
get() { return value
; }
166 const unwrapped_type
& unwrap() { return value
; }
168 const U
& unwrap() { return any_cast
<const U
&>(value
); }
172 struct value_holder
<T
&>
174 typedef typename value_holder
<T
>::type
& type
;
175 typedef typename value_holder
<T
>::unwrapped_type unwrapped_type
;
176 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
178 value_holder(U
&& u
) : impl(std::forward
<U
>(u
)) {}
181 value_holder(U
& u
) : impl(u
) {}
183 value_holder(const U
& u
) : impl(u
) {}
185 value_holder
<T
> impl
;
186 type
get() { return impl
.value
; }
187 const unwrapped_type
& unwrap() { return unwrap
<unwrapped_type
>(); }
189 const U
& unwrap() { return impl
.template unwrap
<unwrapped_type
>(); }
193 struct value_holder
<const T
&>
195 typedef const typename value_holder
<T
>::type
& type
;
196 typedef typename value_holder
<T
>::unwrapped_type unwrapped_type
;
197 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
199 value_holder(U
&& u
) : impl(std::forward
<U
>(u
)) {}
202 value_holder(U
& u
) : impl(u
) {}
204 value_holder(const U
& u
) : impl(u
) {}
206 value_holder
<T
> impl
;
207 type
get() { return impl
.value
; }
208 const unwrapped_type
& unwrap() { return unwrap
<unwrapped_type
>(); }
210 const U
& unwrap() { return impl
.template unwrap
<unwrapped_type
>(); }
213 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
216 struct value_holder
<T
&&>
218 typedef typename value_holder
<T
>::type
&& type
;
219 typedef typename value_holder
<T
>::unwrapped_type unwrapped_type
;
221 value_holder(U
&& u
) : impl(std::forward
<U
>(u
)) {}
222 value_holder
<T
> impl
;
223 type
get() { return std::move(impl
.value
); }
224 const unwrapped_type
& unwrap() { return unwrap
<unwrapped_type
>(); }
226 const U
& unwrap() { return impl
.template unwrap
<unwrapped_type
>(); }
231 template<class T
, class A
>
232 struct value_holder
<T(A
)>
234 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
236 value_holder(U
&& u
) : init(std::forward
<U
>(u
)), impl(init
.get()) {}
239 value_holder(U
& u
) : init(u
), impl(init
.get()) {}
241 value_holder(const U
& u
) : init(u
), impl(init
.get()) {}
243 value_holder
<A
> init
;
244 value_holder
<T
> impl
;
245 typedef typename value_holder
<T
>::type type
;
246 typedef typename value_holder
<A
>::unwrapped_type unwrapped_type
;
247 type
get() { return impl
.get(); }
248 const unwrapped_type
& unwrap() { return unwrap
<unwrapped_type
>(); }
250 const U
& unwrap() { return impl
.template unwrap
<unwrapped_type
>(); }
253 #define TEST_ASSIGNMENT_I(LHS, RHS, result, ptr_op, R) \
256 value_holder<LHS> lhs(17); \
257 value_holder<RHS> rhs(23); \
258 const void * original = any_cast<const void*>(&lhs.get()); \
259 lhs.get() = rhs.get(); \
260 typedef value_holder<R>::unwrapped_type expected_type; \
261 if(const expected_type* ptr = \
262 any_cast<const expected_type*>(&lhs.get())) \
264 BOOST_TEST(ptr->value == 23); \
265 BOOST_TEST(ptr->info == (result)); \
266 BOOST_TEST(ptr ptr_op original); \
270 BOOST_ERROR("Wrong type: Expected " \
271 << boost::core::demangle(typeid(expected_type).name()) \
273 << boost::core::demangle(typeid_of(lhs.get()).name())); \
276 catch(bad_function_call&) \
278 BOOST_ERROR("bad_function_call in " \
279 << demangle(typeid(value_holder<LHS>::type).name()) \
281 << demangle(typeid(value_holder<RHS>::type).name())); \
284 #define TEST_ASSIGNMENT_id_dispatch(LHS, RHS, result) \
285 TEST_ASSIGNMENT_I(LHS, RHS, result, ==, LHS)
287 #define TEST_ASSIGNMENT_id_fallback(LHS, RHS, result) \
288 TEST_ASSIGNMENT_I(LHS, RHS, result, !=, RHS)
290 #define TEST_ASSIGNMENT_id_throw(LHS, RHS, result) \
292 value_holder<LHS> lhs(17); \
293 value_holder<RHS> rhs(23); \
294 BOOST_CHECK_THROW(lhs.get() = rhs.get(), bad_function_call); \
297 #define TEST_ASSIGNMENT(LHS, RHS, tag, result) \
298 BOOST_PP_CAT(TEST_ASSIGNMENT_, tag)(LHS, RHS, result)
300 BOOST_AUTO_TEST_CASE(test_nothing
)
302 // Nothing to test. Assignment is entirely illegal
305 BOOST_AUTO_TEST_CASE(test_nothing_relaxed
)
307 typedef ::boost::mpl::vector
<
310 constructible
<_self(int)>,
313 typedef test_class
<int, false, false, false, false> test_type
;
315 typedef any
<test_concept
> any_val
;
316 typedef any
<test_concept
, _self
&> any_ref
;
318 // Compile-time check.
319 binding
<test_concept
> test_binding
= make_binding
< ::boost::mpl::map
< ::boost::mpl::pair
<_self
, test_type
> > >();
320 any_val
v1(test_binding
, 1);
322 // assignment of same type
324 // different stored type
328 // assignment to a reference
329 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(int), id_fallback
, id_rvalue
| id_construct
| id_copy
);
330 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(int&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
331 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
332 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
334 // reference with a different type
335 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
336 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
337 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
338 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
340 // reference with raw value
341 TEST_ASSIGNMENT(any_ref
&(int&), int&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
342 TEST_ASSIGNMENT(any_ref
&(int&), long&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
344 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
346 typedef any
<test_concept
, _self
&&> any_rref
;
348 // rvalue reference as the rhs
350 // assignment to an rvalue reference
351 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&&(int), id_fallback
, id_rvalue
| id_construct
| id_copy
);
352 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(int&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
353 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(int&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
354 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(int&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
356 // rvalue reference with a different type
357 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&&(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
358 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
359 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
360 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
362 // rvalue reference with raw value
363 TEST_ASSIGNMENT(any_rref
&(int&&), int&&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
364 TEST_ASSIGNMENT(any_rref
&(int&&), long&&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
368 BOOST_AUTO_TEST_CASE(test_copy_assignable
)
370 typedef ::boost::mpl::vector
<
374 constructible
<_self(int)>
376 typedef test_class
<int, false, false, true, false> test_type
;
378 typedef any
<test_concept
> any_val
;
379 typedef any
<test_concept
, _self
&> any_ref
;
380 typedef any
<test_concept
, const _self
&> any_cref
;
382 // Compile-time check.
383 binding
<test_concept
> test_binding
= make_binding
< ::boost::mpl::map
< ::boost::mpl::pair
<_self
, test_type
> > >();
384 any_val
v1(test_binding
, 1);
386 // assignment of same type
387 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
388 TEST_ASSIGNMENT(any_val
&(int), any_val
&&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
390 TEST_ASSIGNMENT(any_val
&(int), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
391 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
392 TEST_ASSIGNMENT(any_val
&(int), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
393 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
394 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
395 TEST_ASSIGNMENT(any_val
&(int), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
396 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
397 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
399 // different stored type (undefined behavior)
401 // raw value (compile error)
403 // assignment to a reference
404 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
405 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
407 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
408 TEST_ASSIGNMENT(any_ref
&(int&), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
409 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
410 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
411 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
412 TEST_ASSIGNMENT(any_ref
&(int&), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
413 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
414 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
416 // reference with a different type (undefined behavior)
418 // reference with raw value (compile error)
420 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
422 typedef any
<test_concept
, _self
&&> any_rref
;
424 // rvalue reference as the rhs
425 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
426 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
427 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
428 TEST_ASSIGNMENT(any_ref
&(int&), any_rref(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
429 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
430 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
const&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
432 // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
433 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
434 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
435 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
436 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
437 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
438 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
439 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
440 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
441 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
442 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
443 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
444 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
446 // rvalue reference with a different type (undefined behavior)
448 // rvalue reference with raw value (compile error)
452 BOOST_AUTO_TEST_CASE(test_copy_assignable_relaxed
)
454 typedef ::boost::mpl::vector
<
458 constructible
<_self(int)>,
461 typedef test_class
<int, false, false, true, false> test_type
;
463 typedef any
<test_concept
> any_val
;
464 typedef any
<test_concept
, _self
&> any_ref
;
465 typedef any
<test_concept
, const _self
&> any_cref
;
467 // Compile-time check.
468 binding
<test_concept
> test_binding
= make_binding
< ::boost::mpl::map
< ::boost::mpl::pair
<_self
, test_type
> > >();
469 any_val
v1(test_binding
, 1);
471 // assignment of same type
472 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
473 TEST_ASSIGNMENT(any_val
&(int), any_val
&&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
475 TEST_ASSIGNMENT(any_val
&(int), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
476 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
477 TEST_ASSIGNMENT(any_val
&(int), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
478 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
479 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
480 TEST_ASSIGNMENT(any_val
&(int), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
481 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
482 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
484 // different stored type
485 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
486 TEST_ASSIGNMENT(any_val
&(int), any_val
&&(long), id_throw
, 0);
488 TEST_ASSIGNMENT(any_val
&(int), any_val
&(long), id_throw
, 0);
489 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(long), id_throw
, 0);
490 TEST_ASSIGNMENT(any_val
&(int), any_ref(long&), id_throw
, 0);
491 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(long&), id_throw
, 0);
492 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(long&), id_throw
, 0);
493 TEST_ASSIGNMENT(any_val
&(int), any_cref(long&), id_throw
, 0);
494 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(long&), id_throw
, 0);
495 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(long&), id_throw
, 0);
498 TEST_ASSIGNMENT(any_val
&(int), int, id_fallback
, id_rvalue
| id_construct
| id_copy
);
499 TEST_ASSIGNMENT(any_val
&(int), int&, id_fallback
, id_maybe_const_lvalue
| id_construct
| id_copy
);
500 TEST_ASSIGNMENT(any_val
&(int), int const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
501 TEST_ASSIGNMENT(any_val
&(int), long, id_fallback
, id_rvalue
| id_construct
| id_copy
);
502 TEST_ASSIGNMENT(any_val
&(int), long&, id_fallback
, id_maybe_const_lvalue
| id_construct
| id_copy
);
503 TEST_ASSIGNMENT(any_val
&(int), long const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
505 // assignment to a reference
506 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
507 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
509 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
510 TEST_ASSIGNMENT(any_ref
&(int&), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
511 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
512 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
513 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
514 TEST_ASSIGNMENT(any_ref
&(int&), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
515 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
516 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
518 // reference with a different type
519 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
520 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&&(long), id_throw
, 0);
522 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
523 TEST_ASSIGNMENT(any_ref
&(int&), any_val
const&(long), id_throw
, 0);
524 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
525 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
526 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
527 TEST_ASSIGNMENT(any_ref
&(int&), any_cref(long&), id_throw
, 0);
528 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
&(long&), id_throw
, 0);
529 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
const&(long&), id_throw
, 0);
531 // reference with raw value
532 TEST_ASSIGNMENT(any_ref
&(int&), int&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
533 TEST_ASSIGNMENT(any_ref
&(int&), long&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
535 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
537 typedef any
<test_concept
, _self
&&> any_rref
;
539 // rvalue reference as the rhs
540 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
541 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
542 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
543 TEST_ASSIGNMENT(any_val
&(int), any_rref(long&&), id_throw
, 0);
544 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(long&&), id_throw
, 0);
545 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(long&&), id_throw
, );
546 TEST_ASSIGNMENT(any_ref
&(int&), any_rref(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
547 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
548 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
const&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
549 TEST_ASSIGNMENT(any_ref
&(int&), any_rref(long&&), id_throw
, 0);
550 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
&(long&&), id_throw
, 0);
551 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
const&(long&&), id_throw
, 0);
553 // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
554 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
555 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
556 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
557 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
558 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
559 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
560 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
561 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
562 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
563 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
564 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
565 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
567 // rvalue reference with a different type
568 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&&(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
569 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&(long), id_throw
, 0);
570 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
const&(long), id_throw
, 0);
571 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref(long&), id_throw
, 0);
572 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
&(long&), id_throw
, 0);
573 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
const&(long&), id_throw
, 0);
574 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref(long&), id_throw
, 0);
575 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
&(long&), id_throw
, 0);
576 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
const&(long&), id_throw
, 0);
577 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
578 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
579 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
581 // rvalue reference with raw value
582 TEST_ASSIGNMENT(any_rref
&(int&&), int&&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
583 TEST_ASSIGNMENT(any_rref
&(int&&), long&&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
587 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
589 BOOST_AUTO_TEST_CASE(test_move_assignable
)
591 typedef ::boost::mpl::vector
<
595 constructible
<_self(int)>
597 typedef test_class
<int, false, false, false, true> test_type
;
599 typedef any
<test_concept
> any_val
;
600 typedef any
<test_concept
, _self
&> any_ref
;
602 // Compile-time check.
603 binding
<test_concept
> test_binding
= make_binding
< ::boost::mpl::map
< ::boost::mpl::pair
<_self
, test_type
> > >();
604 any_val
v1(test_binding
, 1);
606 // assignment of same type
607 TEST_ASSIGNMENT(any_val
&(int), any_val
&&(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
609 // different stored type
613 // assignment to a reference
614 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&&(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
616 // reference with a different type
618 // reference with raw value
620 typedef any
<test_concept
, _self
&&> any_rref
;
622 // rvalue reference as the rhs
623 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
624 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
625 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
626 TEST_ASSIGNMENT(any_ref
&(int&), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
627 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
628 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);;
630 // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
631 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&&(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
632 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
633 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
634 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
636 // rvalue reference with a different type
638 // rvalue reference with raw value
641 BOOST_AUTO_TEST_CASE(test_move_assignable_relaxed
)
643 typedef ::boost::mpl::vector
<
647 constructible
<_self(int)>,
650 typedef test_class
<int, false, false, false, true> test_type
;
652 typedef any
<test_concept
> any_val
;
653 typedef any
<test_concept
, _self
&> any_ref
;
655 // Compile-time check.
656 binding
<test_concept
> test_binding
= make_binding
< ::boost::mpl::map
< ::boost::mpl::pair
<_self
, test_type
> > >();
657 any_val
v1(test_binding
, 1);
659 // assignment of same type
660 TEST_ASSIGNMENT(any_val
&(int), any_val
&&(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
662 // different stored type
663 TEST_ASSIGNMENT(any_val
&(int), any_val
&&(long), id_throw
, 0);
667 // assignment to a reference
668 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&&(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
669 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(int), id_fallback
, id_rvalue
| id_construct
| id_copy
);
670 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(int&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
671 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
672 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
674 // reference with a different type
675 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&&(long), id_throw
, 0);
676 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
677 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
678 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
679 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
681 // reference with raw value
682 TEST_ASSIGNMENT(any_ref
&(int&), int&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
683 TEST_ASSIGNMENT(any_ref
&(int&), long&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
685 typedef any
<test_concept
, _self
&&> any_rref
;
687 // rvalue reference as the rhs
688 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
689 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
690 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
691 TEST_ASSIGNMENT(any_val
&(int), any_rref(long&&), id_throw
, 0);
692 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(long&&), id_throw
, 0);
693 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(long&&), id_throw
, 0);
694 TEST_ASSIGNMENT(any_ref
&(int&), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
695 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
696 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
697 TEST_ASSIGNMENT(any_ref
&(int&), any_rref(long&&), id_throw
, 0);
698 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
&(long&&), id_throw
, 0);
699 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
const&(long&&), id_throw
, 0);
701 // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
702 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&&(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
703 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
704 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
705 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
707 // rvalue reference with a different type
708 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&&(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
709 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
710 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
711 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
713 // rvalue reference with raw value
714 TEST_ASSIGNMENT(any_rref
&(int&&), int&&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
715 TEST_ASSIGNMENT(any_rref
&(int&&), long&&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
718 #ifndef BOOST_NO_CXX11_REF_QUALIFIERS
720 BOOST_AUTO_TEST_CASE(test_move_and_copy_assignable
)
722 typedef ::boost::mpl::vector
<
727 constructible
<_self(int)>
729 typedef test_class
<int, false, false, true, true> test_type
;
731 typedef any
<test_concept
> any_val
;
732 typedef any
<test_concept
, _self
&> any_ref
;
733 typedef any
<test_concept
, const _self
&> any_cref
;
735 // Compile-time check.
736 binding
<test_concept
> test_binding
= make_binding
< ::boost::mpl::map
< ::boost::mpl::pair
<_self
, test_type
> > >();
737 any_val
v1(test_binding
, 1);
739 // assignment of same type
740 TEST_ASSIGNMENT(any_val
&(int), any_val
&&(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
741 TEST_ASSIGNMENT(any_val
&(int), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
742 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
743 TEST_ASSIGNMENT(any_val
&(int), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
744 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
745 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
746 TEST_ASSIGNMENT(any_val
&(int), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
747 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
748 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
750 // different stored type (undefined behavior)
752 // raw value (compile error)
754 // assignment to a reference
755 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&&(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
756 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
757 TEST_ASSIGNMENT(any_ref
&(int&), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
758 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
759 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
760 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
761 TEST_ASSIGNMENT(any_ref
&(int&), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
762 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
763 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
765 // reference with a different type (undefined behavior)
767 // reference with raw value (compile error)
769 typedef any
<test_concept
, _self
&&> any_rref
;
771 // rvalue reference as the rhs
772 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
773 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
774 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
775 TEST_ASSIGNMENT(any_ref
&(int&), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
776 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
777 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
779 // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
780 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&&(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
781 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
782 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
783 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
784 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
785 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
786 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
787 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
788 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
789 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
790 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
791 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
793 // rvalue reference with a different type (undefined behavior)
795 // rvalue reference with raw value (compile error)
798 BOOST_AUTO_TEST_CASE(test_move_and_copy_assignable_relaxed
)
800 typedef ::boost::mpl::vector
<
805 constructible
<_self(int)>,
808 typedef test_class
<int, false, false, true, true> test_type
;
810 typedef any
<test_concept
> any_val
;
811 typedef any
<test_concept
, _self
&> any_ref
;
812 typedef any
<test_concept
, const _self
&> any_cref
;
814 // Compile-time check.
815 binding
<test_concept
> test_binding
= make_binding
< ::boost::mpl::map
< ::boost::mpl::pair
<_self
, test_type
> > >();
816 any_val
v1(test_binding
, 1);
818 // assignment of same type
819 TEST_ASSIGNMENT(any_val
&(int), any_val
&&(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
820 TEST_ASSIGNMENT(any_val
&(int), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
821 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
822 TEST_ASSIGNMENT(any_val
&(int), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
823 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
824 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
825 TEST_ASSIGNMENT(any_val
&(int), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
826 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
827 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
829 // different stored type
830 TEST_ASSIGNMENT(any_val
&(int), any_val
&&(long), id_throw
, 0);
831 TEST_ASSIGNMENT(any_val
&(int), any_val
&(long), id_throw
, 0);
832 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(long), id_throw
, 0);
833 TEST_ASSIGNMENT(any_val
&(int), any_ref(long&), id_throw
, 0);
834 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(long&), id_throw
, 0);
835 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(long&), id_throw
, 0);
836 TEST_ASSIGNMENT(any_val
&(int), any_cref(long&), id_throw
, 0);
837 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(long&), id_throw
, 0);
838 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(long&), id_throw
, 0);
841 TEST_ASSIGNMENT(any_val
&(int), int, id_fallback
, id_rvalue
| id_construct
| id_copy
);
842 TEST_ASSIGNMENT(any_val
&(int), int&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
843 TEST_ASSIGNMENT(any_val
&(int), int const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
844 TEST_ASSIGNMENT(any_val
&(int), long, id_fallback
, id_rvalue
| id_construct
| id_copy
);
845 TEST_ASSIGNMENT(any_val
&(int), long&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
846 TEST_ASSIGNMENT(any_val
&(int), long const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
848 // assignment to a reference
849 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&&(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
850 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
851 TEST_ASSIGNMENT(any_ref
&(int&), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
852 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
853 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
854 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
855 TEST_ASSIGNMENT(any_ref
&(int&), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
856 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
857 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
859 // reference with a different type
860 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&&(long), id_throw
, 0);
861 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
862 TEST_ASSIGNMENT(any_ref
&(int&), any_val
const&(long), id_throw
, 0);
863 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
864 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
865 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
866 TEST_ASSIGNMENT(any_ref
&(int&), any_cref(long&), id_throw
, 0);
867 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
&(long&), id_throw
, 0);
868 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
const&(long&), id_throw
, 0);
870 // reference with raw value
871 TEST_ASSIGNMENT(any_ref
&(int&), int&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
872 TEST_ASSIGNMENT(any_ref
&(int&), long&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
874 typedef any
<test_concept
, _self
&&> any_rref
;
876 // rvalue reference as the rhs
877 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
878 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
879 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
880 TEST_ASSIGNMENT(any_val
&(int), any_rref(long&&), id_throw
, 0);
881 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(long&&), id_throw
, 0);
882 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(long&&), id_throw
, 0);
883 TEST_ASSIGNMENT(any_ref
&(int&), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
884 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
885 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
886 TEST_ASSIGNMENT(any_ref
&(int&), any_rref(long&&), id_throw
, 0);
887 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
&(long&&), id_throw
, 0);
888 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
const&(long&&), id_throw
, 0);
890 // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
891 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&&(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
892 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
893 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
894 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
895 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
896 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
897 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
898 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
899 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
900 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
901 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
902 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
904 // rvalue reference with a different type
905 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&&(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
906 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&(long), id_throw
, 0);
907 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
const&(long), id_throw
, 0);
908 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref(long&), id_throw
, 0);
909 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
&(long&), id_throw
, 0);
910 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
const&(long&), id_throw
, 0);
911 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref(long&), id_throw
, 0);
912 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
&(long&), id_throw
, 0);
913 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
const&(long&), id_throw
, 0);
914 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
915 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
916 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
918 // rvalue reference with raw value
919 TEST_ASSIGNMENT(any_rref
&(int&&), int&&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
920 TEST_ASSIGNMENT(any_rref
&(int&&), long&&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
923 #endif // BOOST_NO_CXX11_REF_QUALIFIERS
925 #endif // BOOST_NO_CXX11_RVALUE_REFERENCES
927 BOOST_AUTO_TEST_CASE(test_copy_constructible_only
)
929 // Nothing to test. Assignment is entirely illegal
932 BOOST_AUTO_TEST_CASE(test_copy_constructible_only_relaxed
)
934 typedef ::boost::mpl::vector
<
938 typedef test_class
<int, true, false, false, false> test_type
;
940 typedef any
<test_concept
> any_val
;
941 typedef any
<test_concept
, _self
&> any_ref
;
942 typedef any
<test_concept
, const _self
&> any_cref
;
944 // Compile-time check.
945 TEST_ASSIGNMENT(any_val
&(int), test_type
&, id_fallback
, id_maybe_const_lvalue
| id_construct
| id_copy
);
946 TEST_ASSIGNMENT(any_val
&(int), test_type
const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
948 // assignment of same type
949 TEST_ASSIGNMENT(any_val
&(int), any_val(int), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
950 TEST_ASSIGNMENT(any_val
&(int), any_val
&(int), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
951 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(int), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
952 TEST_ASSIGNMENT(any_val
&(int), any_ref(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
953 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
954 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
955 TEST_ASSIGNMENT(any_val
&(int), any_cref(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
956 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
957 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
959 // different stored type
960 TEST_ASSIGNMENT(any_val
&(int), any_val(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
961 TEST_ASSIGNMENT(any_val
&(int), any_val
&(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
962 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
963 TEST_ASSIGNMENT(any_val
&(int), any_ref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
964 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
965 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
966 TEST_ASSIGNMENT(any_val
&(int), any_cref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
967 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
968 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
971 TEST_ASSIGNMENT(any_val
&(int), int, id_fallback
, id_rvalue
| id_construct
| id_copy
);
972 TEST_ASSIGNMENT(any_val
&(int), int&, id_fallback
, id_maybe_const_lvalue
| id_construct
| id_copy
);
973 TEST_ASSIGNMENT(any_val
&(int), int const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
974 TEST_ASSIGNMENT(any_val
&(int), long, id_fallback
, id_rvalue
| id_construct
| id_copy
);
975 TEST_ASSIGNMENT(any_val
&(int), long&, id_fallback
, id_maybe_const_lvalue
| id_construct
| id_copy
);
976 TEST_ASSIGNMENT(any_val
&(int), long const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
978 // assignment to a reference
979 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(int), id_fallback
, id_rvalue
| id_construct
| id_copy
);
980 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(int&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
981 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
982 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
984 // reference with a different type
985 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
986 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
987 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
988 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
990 // reference with raw value
991 TEST_ASSIGNMENT(any_ref
&(int&), int&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
992 TEST_ASSIGNMENT(any_ref
&(int&), long&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
994 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
996 typedef any
<test_concept
, _self
&&> any_rref
;
998 // rvalue reference as the rhs
999 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1000 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1001 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1002 TEST_ASSIGNMENT(any_val
&(int), any_rref(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1003 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1004 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1006 // assignment to an rvalue reference
1007 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&&(int), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1008 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(int&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1009 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(int&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1010 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(int&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1012 // rvalue reference with a different type
1013 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&&(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1014 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1015 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1016 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1018 // rvalue reference with raw value
1019 TEST_ASSIGNMENT(any_rref
&(int&&), int&&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1020 TEST_ASSIGNMENT(any_rref
&(int&&), long&&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1024 BOOST_AUTO_TEST_CASE(test_copy
)
1026 typedef ::boost::mpl::vector
<
1030 typedef test_class
<int, true, false, true, false> test_type
;
1032 typedef any
<test_concept
> any_val
;
1033 typedef any
<test_concept
, _self
&> any_ref
;
1034 typedef any
<test_concept
, const _self
&> any_cref
;
1036 // Compile-time check.
1037 TEST_ASSIGNMENT(any_val
&(test_type
&), any_val
&(test_type
&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1038 TEST_ASSIGNMENT(any_val
&(test_type
&), any_val
&(const test_type
&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1040 // assignment of same type
1041 TEST_ASSIGNMENT(any_val
&(int), any_val(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1042 TEST_ASSIGNMENT(any_val
&(int), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1043 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1044 TEST_ASSIGNMENT(any_val
&(int), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1045 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1046 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1047 TEST_ASSIGNMENT(any_val
&(int), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1048 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1049 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1051 // different stored type (undefined behavior)
1053 // raw value (compile error)
1055 // assignment to a reference
1056 TEST_ASSIGNMENT(any_ref
&(int&), any_val(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1057 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1058 TEST_ASSIGNMENT(any_ref
&(int&), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1059 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1060 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1061 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1062 TEST_ASSIGNMENT(any_ref
&(int&), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1063 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1064 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1066 // reference with a different type (undefined behavior)
1068 // reference with raw value (compile error)
1070 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1072 typedef any
<test_concept
, _self
&&> any_rref
;
1074 // rvalue reference as the rhs
1075 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1076 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1077 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1078 TEST_ASSIGNMENT(any_ref
&(int&), any_rref(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1079 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1080 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
const&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1082 // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
1083 TEST_ASSIGNMENT(any_rref
&(int&&), any_val(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1084 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1085 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1086 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1087 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1088 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1089 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1090 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1091 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1092 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1093 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1094 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1096 // rvalue reference with a different type (undefined behavior)
1098 // rvalue reference with raw value (compile error)
1102 BOOST_AUTO_TEST_CASE(test_copy_relaxed
)
1104 typedef ::boost::mpl::vector
<
1109 typedef test_class
<int, true, false, true, false> test_type
;
1111 typedef any
<test_concept
> any_val
;
1112 typedef any
<test_concept
, _self
&> any_ref
;
1113 typedef any
<test_concept
, const _self
&> any_cref
;
1115 // Compile-time check.
1116 TEST_ASSIGNMENT(any_val
&(int), test_type
&, id_fallback
, id_maybe_const_lvalue
| id_construct
| id_copy
);
1117 TEST_ASSIGNMENT(any_val
&(int), test_type
const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1119 // assignment of same type
1120 TEST_ASSIGNMENT(any_val
&(int), any_val(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1121 TEST_ASSIGNMENT(any_val
&(int), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1122 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1123 TEST_ASSIGNMENT(any_val
&(int), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1124 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1125 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1126 TEST_ASSIGNMENT(any_val
&(int), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1127 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1128 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1130 // different stored type
1131 TEST_ASSIGNMENT(any_val
&(int), any_val(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1132 TEST_ASSIGNMENT(any_val
&(int), any_val
&(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1133 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1134 TEST_ASSIGNMENT(any_val
&(int), any_ref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1135 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1136 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1137 TEST_ASSIGNMENT(any_val
&(int), any_cref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1138 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1139 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1142 TEST_ASSIGNMENT(any_val
&(int), int, id_fallback
, id_rvalue
| id_construct
| id_copy
);
1143 TEST_ASSIGNMENT(any_val
&(int), int&, id_fallback
, id_maybe_const_lvalue
| id_construct
| id_copy
);
1144 TEST_ASSIGNMENT(any_val
&(int), int const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1145 TEST_ASSIGNMENT(any_val
&(int), long, id_fallback
, id_rvalue
| id_construct
| id_copy
);
1146 TEST_ASSIGNMENT(any_val
&(int), long&, id_fallback
, id_maybe_const_lvalue
| id_construct
| id_copy
);
1147 TEST_ASSIGNMENT(any_val
&(int), long const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1149 // assignment to a reference
1150 TEST_ASSIGNMENT(any_ref
&(int&), any_val(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1151 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1152 TEST_ASSIGNMENT(any_ref
&(int&), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1153 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1154 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1155 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1156 TEST_ASSIGNMENT(any_ref
&(int&), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1157 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1158 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1160 // reference with a different type
1161 TEST_ASSIGNMENT(any_ref
&(int&), any_val(long), id_throw
, 0);
1162 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1163 TEST_ASSIGNMENT(any_ref
&(int&), any_val
const&(long), id_throw
, 0);
1164 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1165 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1166 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1167 TEST_ASSIGNMENT(any_ref
&(int&), any_cref(long&), id_throw
, 0);
1168 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
&(long&), id_throw
, 0);
1169 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
const&(long&), id_throw
, 0);
1171 // reference with raw value
1172 TEST_ASSIGNMENT(any_ref
&(int&), int&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1173 TEST_ASSIGNMENT(any_ref
&(int&), long&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1175 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1177 typedef any
<test_concept
, _self
&&> any_rref
;
1179 // rvalue reference as the rhs
1180 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1181 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1182 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1183 TEST_ASSIGNMENT(any_val
&(int), any_rref(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1184 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1185 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1186 TEST_ASSIGNMENT(any_ref
&(int&), any_rref(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1187 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1188 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
const&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1189 TEST_ASSIGNMENT(any_ref
&(int&), any_rref(long&&), id_throw
, 0);
1190 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
&(long&&), id_throw
, 0);
1191 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
const&(long&&), id_throw
, 0);
1193 // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
1194 TEST_ASSIGNMENT(any_rref
&(int&&), any_val(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1195 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1196 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1197 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1198 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1199 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1200 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1201 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1202 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1203 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1204 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1205 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1207 // rvalue reference with a different type
1208 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&&(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1209 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&(long), id_throw
, 0);
1210 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
const&(long), id_throw
, 0);
1211 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref(long&), id_throw
, 0);
1212 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
&(long&), id_throw
, 0);
1213 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
const&(long&), id_throw
, 0);
1214 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref(long&), id_throw
, 0);
1215 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
&(long&), id_throw
, 0);
1216 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
const&(long&), id_throw
, 0);
1217 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1218 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1219 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1221 // rvalue reference with raw value
1222 TEST_ASSIGNMENT(any_rref
&(int&&), int&&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1223 TEST_ASSIGNMENT(any_rref
&(int&&), long&&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1228 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1230 BOOST_AUTO_TEST_CASE(test_copy_constructable_move_assignable
)
1232 typedef ::boost::mpl::vector
<
1236 typedef test_class
<int, true, false, false, true> test_type
;
1238 typedef any
<test_concept
> any_val
;
1239 typedef any
<test_concept
, _self
&> any_ref
;
1241 // Compile-time check.
1242 TEST_ASSIGNMENT(any_val
&(test_type
&), any_val(test_type
&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1243 TEST_ASSIGNMENT(any_val
&(test_type
&), any_val(test_type
const&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1245 // assignment of same type
1246 TEST_ASSIGNMENT(any_val
&(int), any_val(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1248 // different stored type
1252 // assignment to a reference
1253 TEST_ASSIGNMENT(any_ref
&(int&), any_val(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1255 // reference with a different type
1257 // reference with raw value
1259 typedef any
<test_concept
, _self
&&> any_rref
;
1261 // rvalue reference as the rhs
1262 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1263 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1264 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1265 TEST_ASSIGNMENT(any_ref
&(int&), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1266 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1267 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);;
1269 // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
1270 TEST_ASSIGNMENT(any_rref
&(int&&), any_val(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1271 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1272 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1273 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1275 // rvalue reference with a different type
1277 // rvalue reference with raw value
1280 BOOST_AUTO_TEST_CASE(test_copy_constructable_move_assignable_relaxed
)
1282 typedef ::boost::mpl::vector
<
1287 typedef test_class
<int, true, false, false, true> test_type
;
1289 typedef any
<test_concept
> any_val
;
1290 typedef any
<test_concept
, _self
&> any_ref
;
1291 typedef any
<test_concept
, const _self
&> any_cref
;
1293 // Compile-time check.
1294 TEST_ASSIGNMENT(any_val
&(int), test_type
&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
1295 TEST_ASSIGNMENT(any_val
&(int), test_type
const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1297 // assignment of same type
1298 TEST_ASSIGNMENT(any_val
&(int), any_val(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1299 TEST_ASSIGNMENT(any_val
&(int), any_val
&(int), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1300 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(int), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1301 TEST_ASSIGNMENT(any_val
&(int), any_ref(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1302 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1303 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1304 TEST_ASSIGNMENT(any_val
&(int), any_cref(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1305 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1306 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1308 // different stored type
1309 TEST_ASSIGNMENT(any_val
&(int), any_val(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1310 TEST_ASSIGNMENT(any_val
&(int), any_val
&(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1311 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1312 TEST_ASSIGNMENT(any_val
&(int), any_ref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1313 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1314 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1315 TEST_ASSIGNMENT(any_val
&(int), any_cref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1316 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1317 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1320 TEST_ASSIGNMENT(any_val
&(int), int, id_fallback
, id_rvalue
| id_construct
| id_copy
);
1321 TEST_ASSIGNMENT(any_val
&(int), int&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
1322 TEST_ASSIGNMENT(any_val
&(int), int const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1323 TEST_ASSIGNMENT(any_val
&(int), long, id_fallback
, id_rvalue
| id_construct
| id_copy
);
1324 TEST_ASSIGNMENT(any_val
&(int), long&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
1325 TEST_ASSIGNMENT(any_val
&(int), long const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1327 // assignment to a reference
1328 TEST_ASSIGNMENT(any_ref
&(int&), any_val(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1329 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(int), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1330 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(int&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1331 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1332 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1334 // reference with a different type
1335 TEST_ASSIGNMENT(any_ref
&(int&), any_val(long), id_throw
, 0);
1336 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1337 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1338 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1339 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1341 // reference with raw value
1342 TEST_ASSIGNMENT(any_ref
&(int&), int&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1343 TEST_ASSIGNMENT(any_ref
&(int&), long&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1345 typedef any
<test_concept
, _self
&&> any_rref
;
1347 // rvalue reference as the rhs
1348 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1349 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1350 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1351 TEST_ASSIGNMENT(any_val
&(int), any_rref(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1352 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1353 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1354 TEST_ASSIGNMENT(any_ref
&(int&), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1355 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1356 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1357 TEST_ASSIGNMENT(any_ref
&(int&), any_rref(long&&), id_throw
, 0);
1358 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
&(long&&), id_throw
, 0);
1359 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
const&(long&&), id_throw
, 0);
1361 // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
1362 TEST_ASSIGNMENT(any_rref
&(int&&), any_val(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1363 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1364 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1365 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1367 // rvalue reference with a different type
1368 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&&(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1369 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1370 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1371 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1373 // rvalue reference with raw value
1374 TEST_ASSIGNMENT(any_rref
&(int&&), int&&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1375 TEST_ASSIGNMENT(any_rref
&(int&&), long&&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1378 #ifndef BOOST_NO_CXX11_REF_QUALIFIERS
1380 BOOST_AUTO_TEST_CASE(test_copy_constructible_move_and_copy_assignable
)
1382 typedef ::boost::mpl::vector
<
1387 typedef test_class
<int, true, false, true, true> test_type
;
1389 typedef any
<test_concept
> any_val
;
1390 typedef any
<test_concept
, _self
&> any_ref
;
1391 typedef any
<test_concept
, const _self
&> any_cref
;
1393 // Compile-time check.
1394 TEST_ASSIGNMENT(any_val
&(test_type
&), any_val
&(test_type
&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1395 TEST_ASSIGNMENT(any_val
&(test_type
&), any_val
&(const test_type
&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1397 // assignment of same type
1398 TEST_ASSIGNMENT(any_val
&(int), any_val(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1399 TEST_ASSIGNMENT(any_val
&(int), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1400 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1401 TEST_ASSIGNMENT(any_val
&(int), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1402 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1403 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1404 TEST_ASSIGNMENT(any_val
&(int), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1405 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1406 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1408 // different stored type (undefined behavior)
1410 // raw value (compile error)
1412 // assignment to a reference
1413 TEST_ASSIGNMENT(any_ref
&(int&), any_val(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1414 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1415 TEST_ASSIGNMENT(any_ref
&(int&), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1416 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1417 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1418 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1419 TEST_ASSIGNMENT(any_ref
&(int&), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1420 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1421 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1423 // reference with a different type (undefined behavior)
1425 // reference with raw value (compile error)
1427 typedef any
<test_concept
, _self
&&> any_rref
;
1429 // rvalue reference as the rhs
1430 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1431 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1432 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1433 TEST_ASSIGNMENT(any_ref
&(int&), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1434 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1435 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1437 // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
1438 TEST_ASSIGNMENT(any_rref
&(int&&), any_val(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1439 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1440 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1441 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1442 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1443 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1444 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1445 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1446 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1447 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1448 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1449 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1451 // rvalue reference with a different type (undefined behavior)
1453 // rvalue reference with raw value (compile error)
1456 BOOST_AUTO_TEST_CASE(test_copy_constructible_move_and_copy_assignable_relaxed
)
1458 typedef ::boost::mpl::vector
<
1464 typedef test_class
<int, true, false, true, true> test_type
;
1466 typedef any
<test_concept
> any_val
;
1467 typedef any
<test_concept
, _self
&> any_ref
;
1468 typedef any
<test_concept
, const _self
&> any_cref
;
1470 // Compile-time check.
1471 TEST_ASSIGNMENT(any_val
&(int), test_type
&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
1472 TEST_ASSIGNMENT(any_val
&(int), test_type
const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1474 // assignment of same type
1475 TEST_ASSIGNMENT(any_val
&(int), any_val(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1476 TEST_ASSIGNMENT(any_val
&(int), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1477 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1478 TEST_ASSIGNMENT(any_val
&(int), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1479 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1480 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1481 TEST_ASSIGNMENT(any_val
&(int), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1482 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1483 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1485 // different stored type
1486 TEST_ASSIGNMENT(any_val
&(int), any_val(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1487 TEST_ASSIGNMENT(any_val
&(int), any_val
&(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1488 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1489 TEST_ASSIGNMENT(any_val
&(int), any_ref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1490 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1491 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1492 TEST_ASSIGNMENT(any_val
&(int), any_cref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1493 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1494 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1497 TEST_ASSIGNMENT(any_val
&(int), int, id_fallback
, id_rvalue
| id_construct
| id_copy
);
1498 TEST_ASSIGNMENT(any_val
&(int), int&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
1499 TEST_ASSIGNMENT(any_val
&(int), int const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1500 TEST_ASSIGNMENT(any_val
&(int), long, id_fallback
, id_rvalue
| id_construct
| id_copy
);
1501 TEST_ASSIGNMENT(any_val
&(int), long&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
1502 TEST_ASSIGNMENT(any_val
&(int), long const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1504 // assignment to a reference
1505 TEST_ASSIGNMENT(any_ref
&(int&), any_val(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1506 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1507 TEST_ASSIGNMENT(any_ref
&(int&), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1508 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1509 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1510 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1511 TEST_ASSIGNMENT(any_ref
&(int&), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1512 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1513 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1515 // reference with a different type
1516 TEST_ASSIGNMENT(any_ref
&(int&), any_val(long), id_throw
, 0);
1517 TEST_ASSIGNMENT(any_ref
&(int&), any_val
&(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1518 TEST_ASSIGNMENT(any_ref
&(int&), any_val
const&(long), id_throw
, 0);
1519 TEST_ASSIGNMENT(any_ref
&(int&), any_ref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1520 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1521 TEST_ASSIGNMENT(any_ref
&(int&), any_ref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1522 TEST_ASSIGNMENT(any_ref
&(int&), any_cref(long&), id_throw
, 0);
1523 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
&(long&), id_throw
, 0);
1524 TEST_ASSIGNMENT(any_ref
&(int&), any_cref
const&(long&), id_throw
, 0);
1526 // reference with raw value
1527 TEST_ASSIGNMENT(any_ref
&(int&), int&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1528 TEST_ASSIGNMENT(any_ref
&(int&), long&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1530 typedef any
<test_concept
, _self
&&> any_rref
;
1532 // rvalue reference as the rhs
1533 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1534 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1535 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1536 TEST_ASSIGNMENT(any_val
&(int), any_rref(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1537 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1538 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1539 TEST_ASSIGNMENT(any_ref
&(int&), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1540 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1541 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1542 TEST_ASSIGNMENT(any_ref
&(int&), any_rref(long&&), id_throw
, 0);
1543 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
&(long&&), id_throw
, 0);
1544 TEST_ASSIGNMENT(any_ref
&(int&), any_rref
const&(long&&), id_throw
, 0);
1546 // assignment to an rvalue reference (same dispatching behavior as lvalue reference)
1547 TEST_ASSIGNMENT(any_rref
&(int&&), any_val(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1548 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1549 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1550 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1551 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1552 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1553 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1554 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1555 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1556 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1557 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1558 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1560 // rvalue reference with a different type
1561 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&&(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1562 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
&(long), id_throw
, 0);
1563 TEST_ASSIGNMENT(any_rref
&(int&&), any_val
const&(long), id_throw
, 0);
1564 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref(long&), id_throw
, 0);
1565 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
&(long&), id_throw
, 0);
1566 TEST_ASSIGNMENT(any_rref
&(int&&), any_ref
const&(long&), id_throw
, 0);
1567 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref(long&), id_throw
, 0);
1568 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
&(long&), id_throw
, 0);
1569 TEST_ASSIGNMENT(any_rref
&(int&&), any_cref
const&(long&), id_throw
, 0);
1570 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1571 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1572 TEST_ASSIGNMENT(any_rref
&(int&&), any_rref
const&(long&&), id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1574 // rvalue reference with raw value
1575 TEST_ASSIGNMENT(any_rref
&(int&&), int&&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1576 TEST_ASSIGNMENT(any_rref
&(int&&), long&&, id_fallback
, id_const_lvalue
| id_construct
| id_int
);
1579 #endif // BOOST_NO_CXX11_REF_QUALIFIERS
1581 #endif // BOOST_NO_CXX11_RVALUE_REFERENCES
1583 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
1585 BOOST_AUTO_TEST_CASE(test_move_and_copy_constructible_only
)
1587 // Nothing to test. Assignment is entirely illegal
1590 BOOST_AUTO_TEST_CASE(test_move_and_copy_constructible_only_relaxed
)
1592 typedef ::boost::mpl::vector
<
1597 typedef test_class
<int, true, true, false, false> test_type
;
1599 typedef any
<test_concept
> any_val
;
1600 typedef any
<test_concept
, _self
&> any_ref
;
1601 typedef any
<test_concept
, const _self
&> any_cref
;
1602 typedef any
<test_concept
, _self
&&> any_rref
;
1604 // Compile-time check.
1605 TEST_ASSIGNMENT(any_val
&(int), test_type
&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
1606 TEST_ASSIGNMENT(any_val
&(int), test_type
const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1608 // assignment of same type
1609 TEST_ASSIGNMENT(any_val
&(int), any_val(int), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1610 TEST_ASSIGNMENT(any_val
&(int), any_val
&(int), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1611 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(int), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1612 TEST_ASSIGNMENT(any_val
&(int), any_ref(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1613 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1614 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1615 TEST_ASSIGNMENT(any_val
&(int), any_cref(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1616 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1617 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1618 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1619 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1620 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1622 // different stored type
1623 TEST_ASSIGNMENT(any_val
&(int), any_val(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1624 TEST_ASSIGNMENT(any_val
&(int), any_val
&(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1625 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1626 TEST_ASSIGNMENT(any_val
&(int), any_ref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1627 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1628 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1629 TEST_ASSIGNMENT(any_val
&(int), any_cref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1630 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1631 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1632 TEST_ASSIGNMENT(any_val
&(int), any_rref(long&&), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1633 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(long&&), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1634 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(long&&), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1637 TEST_ASSIGNMENT(any_val
&(int), int, id_fallback
, id_rvalue
| id_construct
| id_copy
);
1638 TEST_ASSIGNMENT(any_val
&(int), int&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
1639 TEST_ASSIGNMENT(any_val
&(int), int const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1640 TEST_ASSIGNMENT(any_val
&(int), long, id_fallback
, id_rvalue
| id_construct
| id_copy
);
1641 TEST_ASSIGNMENT(any_val
&(int), long&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
1642 TEST_ASSIGNMENT(any_val
&(int), long const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1645 BOOST_AUTO_TEST_CASE(test_move_and_copy_constructible_copy_assignable
)
1647 typedef ::boost::mpl::vector
<
1652 typedef test_class
<int, true, true, true, false> test_type
;
1654 typedef any
<test_concept
> any_val
;
1655 typedef any
<test_concept
, _self
&> any_ref
;
1656 typedef any
<test_concept
, const _self
&> any_cref
;
1657 typedef any
<test_concept
, _self
&&> any_rref
;
1659 // Compile-time check.
1660 TEST_ASSIGNMENT(any_val
&(test_type
&), any_val
&(test_type
&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1661 TEST_ASSIGNMENT(any_val
&(test_type
&), any_val
&(const test_type
&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1663 // assignment of same type
1664 TEST_ASSIGNMENT(any_val
&(int), any_val(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1665 TEST_ASSIGNMENT(any_val
&(int), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1666 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1667 TEST_ASSIGNMENT(any_val
&(int), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1668 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1669 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1670 TEST_ASSIGNMENT(any_val
&(int), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1671 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1672 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1673 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1674 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1675 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1677 // different stored type (undefined behavior)
1680 BOOST_AUTO_TEST_CASE(test_move_and_copy_constructible_copy_assignable_relaxed
)
1682 typedef ::boost::mpl::vector
<
1688 typedef test_class
<int, true, true, true, false> test_type
;
1690 typedef any
<test_concept
> any_val
;
1691 typedef any
<test_concept
, _self
&> any_ref
;
1692 typedef any
<test_concept
, const _self
&> any_cref
;
1693 typedef any
<test_concept
, _self
&&> any_rref
;
1695 // Compile-time check.
1696 TEST_ASSIGNMENT(any_val
&(int), test_type
&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
1697 TEST_ASSIGNMENT(any_val
&(int), test_type
const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1699 // assignment of same type
1700 TEST_ASSIGNMENT(any_val
&(int), any_val(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1701 TEST_ASSIGNMENT(any_val
&(int), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1702 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1703 TEST_ASSIGNMENT(any_val
&(int), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1704 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1705 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1706 TEST_ASSIGNMENT(any_val
&(int), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1707 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1708 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1709 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1710 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1711 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1713 // different stored type
1714 TEST_ASSIGNMENT(any_val
&(int), any_val(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1715 TEST_ASSIGNMENT(any_val
&(int), any_val
&(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1716 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1717 TEST_ASSIGNMENT(any_val
&(int), any_ref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1718 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1719 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1720 TEST_ASSIGNMENT(any_val
&(int), any_cref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1721 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1722 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1723 TEST_ASSIGNMENT(any_val
&(int), any_rref(long&&), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1724 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(long&&), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1725 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(long&&), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1728 TEST_ASSIGNMENT(any_val
&(int), int, id_fallback
, id_rvalue
| id_construct
| id_copy
);
1729 TEST_ASSIGNMENT(any_val
&(int), int&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
1730 TEST_ASSIGNMENT(any_val
&(int), int const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1731 TEST_ASSIGNMENT(any_val
&(int), long, id_fallback
, id_rvalue
| id_construct
| id_copy
);
1732 TEST_ASSIGNMENT(any_val
&(int), long&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
1733 TEST_ASSIGNMENT(any_val
&(int), long const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1736 BOOST_AUTO_TEST_CASE(test_move_and_copy_constructable_move_assignable
)
1738 typedef ::boost::mpl::vector
<
1743 typedef test_class
<int, true, true, false, true> test_type
;
1745 typedef any
<test_concept
> any_val
;
1746 typedef any
<test_concept
, _self
&&> any_rref
;
1748 // Compile-time check.
1749 TEST_ASSIGNMENT(any_val
&(test_type
&), any_val(test_type
), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1750 TEST_ASSIGNMENT(any_val
&(test_type
&), any_val(test_type
&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1751 TEST_ASSIGNMENT(any_val
&(test_type
&), any_val(test_type
const&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1753 // assignment of same type
1754 TEST_ASSIGNMENT(any_val
&(int), any_val(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1755 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1756 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1757 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1759 // different stored type
1764 BOOST_AUTO_TEST_CASE(test_move_and_copy_constructable_move_assignable_relaxed
)
1766 typedef ::boost::mpl::vector
<
1772 typedef test_class
<int, true, true, false, true> test_type
;
1774 typedef any
<test_concept
> any_val
;
1775 typedef any
<test_concept
, _self
&> any_ref
;
1776 typedef any
<test_concept
, const _self
&> any_cref
;
1777 typedef any
<test_concept
, _self
&&> any_rref
;
1779 // Compile-time check.
1780 TEST_ASSIGNMENT(any_val
&(int), test_type
, id_fallback
, id_rvalue
| id_construct
| id_copy
);
1781 TEST_ASSIGNMENT(any_val
&(int), test_type
&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
1782 TEST_ASSIGNMENT(any_val
&(int), test_type
const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1784 // assignment of same type
1785 TEST_ASSIGNMENT(any_val
&(int), any_val(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1786 TEST_ASSIGNMENT(any_val
&(int), any_val
&(int), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1787 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(int), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1788 TEST_ASSIGNMENT(any_val
&(int), any_ref(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1789 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1790 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1791 TEST_ASSIGNMENT(any_val
&(int), any_cref(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1792 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1793 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(int&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1794 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1795 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1796 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1798 // different stored type
1799 TEST_ASSIGNMENT(any_val
&(int), any_val(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1800 TEST_ASSIGNMENT(any_val
&(int), any_val
&(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1801 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1802 TEST_ASSIGNMENT(any_val
&(int), any_ref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1803 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1804 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1805 TEST_ASSIGNMENT(any_val
&(int), any_cref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1806 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1807 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1808 TEST_ASSIGNMENT(any_val
&(int), any_rref(long&&), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1809 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(long&&), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1810 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(long&&), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1813 TEST_ASSIGNMENT(any_val
&(int), int, id_fallback
, id_rvalue
| id_construct
| id_copy
);
1814 TEST_ASSIGNMENT(any_val
&(int), int&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
1815 TEST_ASSIGNMENT(any_val
&(int), int const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1816 TEST_ASSIGNMENT(any_val
&(int), long, id_fallback
, id_rvalue
| id_construct
| id_copy
);
1817 TEST_ASSIGNMENT(any_val
&(int), long&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
1818 TEST_ASSIGNMENT(any_val
&(int), long const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1821 BOOST_AUTO_TEST_CASE(test_move_and_copy_constructible_move_and_copy_assignable
)
1823 typedef ::boost::mpl::vector
<
1829 typedef test_class
<int, true, true, true, true> test_type
;
1831 typedef any
<test_concept
> any_val
;
1832 typedef any
<test_concept
, _self
&> any_ref
;
1833 typedef any
<test_concept
, const _self
&> any_cref
;
1834 typedef any
<test_concept
, _self
&&> any_rref
;
1836 // Compile-time check.
1837 TEST_ASSIGNMENT(any_val
&(test_type
&), any_val
&(test_type
), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1838 TEST_ASSIGNMENT(any_val
&(test_type
&), any_val
&(test_type
&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1839 TEST_ASSIGNMENT(any_val
&(test_type
&), any_val
&(const test_type
&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1841 // assignment of same type
1842 TEST_ASSIGNMENT(any_val
&(int), any_val(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1843 TEST_ASSIGNMENT(any_val
&(int), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1844 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1845 TEST_ASSIGNMENT(any_val
&(int), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1846 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1847 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1848 TEST_ASSIGNMENT(any_val
&(int), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1849 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1850 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1851 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1852 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1853 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1855 // different stored type (undefined behavior)
1858 BOOST_AUTO_TEST_CASE(test_move_and_copy_constructible_move_and_copy_assignable_relaxed
)
1860 typedef ::boost::mpl::vector
<
1867 typedef test_class
<int, true, true, true, true> test_type
;
1869 typedef any
<test_concept
> any_val
;
1870 typedef any
<test_concept
, _self
&> any_ref
;
1871 typedef any
<test_concept
, const _self
&> any_cref
;
1872 typedef any
<test_concept
, _self
&&> any_rref
;
1874 // Compile-time check.
1875 TEST_ASSIGNMENT(any_val
&(int), test_type
, id_fallback
, id_rvalue
| id_construct
| id_copy
);
1876 TEST_ASSIGNMENT(any_val
&(int), test_type
&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
1877 TEST_ASSIGNMENT(any_val
&(int), test_type
const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1879 // assignment of same type
1880 TEST_ASSIGNMENT(any_val
&(int), any_val(int), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1881 TEST_ASSIGNMENT(any_val
&(int), any_val
&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1882 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(int), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1883 TEST_ASSIGNMENT(any_val
&(int), any_ref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1884 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1885 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1886 TEST_ASSIGNMENT(any_val
&(int), any_cref(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1887 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1888 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(int&), id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1889 TEST_ASSIGNMENT(any_val
&(int), any_rref(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1890 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1891 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(int&&), id_dispatch
, id_rvalue
| id_assign
| id_copy
);
1893 // different stored type
1894 TEST_ASSIGNMENT(any_val
&(int), any_val(long), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1895 TEST_ASSIGNMENT(any_val
&(int), any_val
&(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1896 TEST_ASSIGNMENT(any_val
&(int), any_val
const&(long), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1897 TEST_ASSIGNMENT(any_val
&(int), any_ref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1898 TEST_ASSIGNMENT(any_val
&(int), any_ref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1899 TEST_ASSIGNMENT(any_val
&(int), any_ref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1900 TEST_ASSIGNMENT(any_val
&(int), any_cref(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1901 TEST_ASSIGNMENT(any_val
&(int), any_cref
&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1902 TEST_ASSIGNMENT(any_val
&(int), any_cref
const&(long&), id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1903 TEST_ASSIGNMENT(any_val
&(int), any_rref(long&&), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1904 TEST_ASSIGNMENT(any_val
&(int), any_rref
&(long&&), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1905 TEST_ASSIGNMENT(any_val
&(int), any_rref
const&(long&&), id_fallback
, id_rvalue
| id_construct
| id_copy
);
1908 TEST_ASSIGNMENT(any_val
&(int), int, id_fallback
, id_rvalue
| id_construct
| id_copy
);
1909 TEST_ASSIGNMENT(any_val
&(int), int&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
1910 TEST_ASSIGNMENT(any_val
&(int), int const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1911 TEST_ASSIGNMENT(any_val
&(int), long, id_fallback
, id_rvalue
| id_construct
| id_copy
);
1912 TEST_ASSIGNMENT(any_val
&(int), long&, id_fallback
, id_lvalue
| id_construct
| id_copy
);
1913 TEST_ASSIGNMENT(any_val
&(int), long const&, id_fallback
, id_const_lvalue
| id_construct
| id_copy
);
1916 #endif // BOOST_NO_RVALUE_REFERENCES || BOOST_NO_CXX11_REF_QUALIFIERS
1918 BOOST_AUTO_TEST_CASE(test_basic_int
)
1920 typedef ::boost::mpl::vector
<
1922 assignable
<_self
, copy_tracker
<int> >
1925 typedef any
<test_concept
> any_val
;
1926 typedef any
<test_concept
, _self
&> any_ref
;
1928 TEST_ASSIGNMENT(any_val
&(int), int, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1929 TEST_ASSIGNMENT(any_val
&(int), int&, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1930 TEST_ASSIGNMENT(any_val
&(int), int const&, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1932 TEST_ASSIGNMENT(any_ref
&(int&), int, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1933 TEST_ASSIGNMENT(any_ref
&(int&), int&, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1934 TEST_ASSIGNMENT(any_ref
&(int&), int const&, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1936 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1937 typedef any
<test_concept
, _self
&&> any_rref
;
1938 TEST_ASSIGNMENT(any_rref
&(int&&), int, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1939 TEST_ASSIGNMENT(any_rref
&(int&&), int&, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1940 TEST_ASSIGNMENT(any_rref
&(int&&), int const&, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1944 BOOST_AUTO_TEST_CASE(test_basic_relaxed_int
)
1946 typedef ::boost::mpl::vector
<
1948 assignable
<_self
, copy_tracker
<int> >,
1952 typedef any
<test_concept
> any_val
;
1953 typedef any
<test_concept
, _self
&> any_ref
;
1955 TEST_ASSIGNMENT(any_val
&(int), int, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1956 TEST_ASSIGNMENT(any_val
&(int), int&, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1957 TEST_ASSIGNMENT(any_val
&(int), int const&, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1959 TEST_ASSIGNMENT(any_ref
&(int&), int, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1960 TEST_ASSIGNMENT(any_ref
&(int&), int&, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1961 TEST_ASSIGNMENT(any_ref
&(int&), int const&, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1963 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1964 typedef any
<test_concept
, _self
&&> any_rref
;
1965 TEST_ASSIGNMENT(any_rref
&(int&&), int, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1966 TEST_ASSIGNMENT(any_rref
&(int&&), int&, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1967 TEST_ASSIGNMENT(any_rref
&(int&&), int const&, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1971 BOOST_AUTO_TEST_CASE(test_relaxed_no_copy_int
)
1973 typedef ::boost::mpl::vector
<
1976 assignable
<_self
, copy_tracker
<int> >,
1980 typedef any
<test_concept
> any_val
;
1981 typedef any
<test_concept
, _self
&> any_ref
;
1983 TEST_ASSIGNMENT(any_val
&(int), int, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1984 TEST_ASSIGNMENT(any_val
&(int), int&, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1985 TEST_ASSIGNMENT(any_val
&(int), int const&, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1987 TEST_ASSIGNMENT(any_ref
&(int&), int, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1988 TEST_ASSIGNMENT(any_ref
&(int&), int&, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1989 TEST_ASSIGNMENT(any_ref
&(int&), int const&, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1991 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1992 typedef any
<test_concept
, _self
&&> any_rref
;
1993 TEST_ASSIGNMENT(any_rref
&(int&&), int, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1994 TEST_ASSIGNMENT(any_rref
&(int&&), int&, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1995 TEST_ASSIGNMENT(any_rref
&(int&&), int const&, id_dispatch
, id_const_lvalue
| id_assign
| id_copy
);
1999 BOOST_AUTO_TEST_CASE(test_relaxed_no_assign_int
)
2001 typedef ::boost::mpl::vector
<
2005 any
<test_concept
> x(1);
2007 BOOST_CHECK_EQUAL(any_cast
<int>(x
), 2);
2010 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
2012 struct move_only_assign_int
2014 explicit move_only_assign_int(int i
)
2016 move_only_assign_int(move_only_assign_int
&& other
)
2017 : value(other
.value
) { other
.value
= 0; }
2018 move_only_assign_int
& operator=(move_only_assign_int
&& other
)
2019 { value
= other
.value
; other
.value
= 0; return *this; }
2020 move_only_assign_int
& operator=(int&& i
)
2021 { value
= i
; return *this; }
2024 move_only_assign_int(const move_only_assign_int
&);
2025 move_only_assign_int
& operator=(const move_only_assign_int
&);
2028 struct only_assign_int
2030 explicit only_assign_int(int i
)
2032 only_assign_int
& operator=(int&& i
)
2033 { value
= i
; return *this; }
2036 only_assign_int(only_assign_int
&&);
2037 only_assign_int(const only_assign_int
&);
2038 only_assign_int
& operator=(only_assign_int
&&);
2039 only_assign_int
& operator=(const only_assign_int
&);
2042 struct move_and_copy_assign_int
2044 explicit move_and_copy_assign_int(int i
)
2046 move_and_copy_assign_int
& operator=(move_and_copy_assign_int
&& other
)
2047 { value
= other
.value
; other
= 0; return *this; }
2048 move_and_copy_assign_int
& operator=(const move_and_copy_assign_int
& other
)
2049 { value
= other
.value
; return *this; }
2050 move_and_copy_assign_int
& operator=(int&& i
)
2051 { value
= i
; return *this; }
2052 move_and_copy_assign_int
& operator=(const int& i
)
2053 { value
= i
; return *this; }
2056 move_and_copy_assign_int(move_and_copy_assign_int
&&);
2057 move_and_copy_assign_int(const move_and_copy_assign_int
&);
2060 struct move_and_copy_construct_assign_int
2062 explicit move_and_copy_construct_assign_int(int i
)
2064 move_and_copy_construct_assign_int(move_and_copy_construct_assign_int
&& other
)
2065 : value(other
.value
) { other
.value
= 0; }
2066 move_and_copy_construct_assign_int(const move_and_copy_construct_assign_int
& other
)
2067 : value(other
.value
) {}
2068 move_and_copy_construct_assign_int
& operator=(move_and_copy_construct_assign_int
&& other
)
2069 { value
= other
.value
; other
= 0; return *this; }
2070 move_and_copy_construct_assign_int
& operator=(const move_and_copy_construct_assign_int
& other
)
2071 { value
= other
.value
; return *this; }
2072 move_and_copy_construct_assign_int
& operator=(int&& i
)
2073 { value
= i
; return *this; }
2074 move_and_copy_construct_assign_int
& operator=(const int& i
)
2075 { value
= i
; return *this; }
2079 struct copy_only_assign_int
2081 explicit copy_only_assign_int(int i
)
2083 copy_only_assign_int(const copy_only_assign_int
& other
)
2084 : value(other
.value
) {}
2085 copy_only_assign_int
& operator=(const copy_only_assign_int
& other
)
2086 { value
= other
.value
; return *this; }
2087 copy_only_assign_int
& operator=(int&& i
)
2088 { value
= i
; return *this; }
2089 copy_only_assign_int
& operator=(const int& i
)
2090 { value
= i
; return *this; }
2093 copy_only_assign_int(copy_only_assign_int
&&);
2094 copy_only_assign_int
& operator=(copy_only_assign_int
&&);
2097 struct copy_only_assign_double
2099 explicit copy_only_assign_double(double i
)
2101 copy_only_assign_double(const copy_only_assign_double
& other
)
2102 : value(other
.value
) {}
2103 copy_only_assign_double
& operator=(const copy_only_assign_double
& other
)
2104 { value
= other
.value
; return *this; }
2105 copy_only_assign_double
& operator=(double&& i
)
2106 { value
= i
; return *this; }
2107 copy_only_assign_double
& operator=(const double& i
)
2108 { value
= i
; return *this; }
2111 copy_only_assign_double(copy_only_assign_double
&&);
2112 copy_only_assign_double
& operator=(copy_only_assign_double
&&);
2115 BOOST_AUTO_TEST_CASE(test_movable_basic_int
)
2117 typedef ::boost::mpl::vector
<
2119 move_assignable
<_self
, int>
2121 typedef move_only_assign_int test_type
;
2122 test_type
source_x(1);
2124 any
<test_concept
> x(std::move(source_x
));
2125 test_type
* ip
= any_cast
<test_type
*>(&x
);
2127 BOOST_CHECK_EQUAL(any_cast
<const test_type
&>(x
).value
, 2);
2128 // make sure that we're actually using assignment
2129 // of the underlying object, not copy and swap.
2130 BOOST_CHECK_EQUAL(any_cast
<test_type
*>(&x
), ip
);
2133 BOOST_AUTO_TEST_CASE(test_movable_basic_relaxed_int
)
2135 typedef ::boost::mpl::vector
<
2137 move_assignable
<_self
, int>,
2140 typedef move_only_assign_int test_type
;
2141 test_type
source_x(1);
2143 any
<test_concept
> x(std::move(source_x
));
2144 test_type
* ip
= any_cast
<test_type
*>(&x
);
2146 BOOST_CHECK_EQUAL(any_cast
<const test_type
&>(x
).value
, 2);
2147 // make sure that we're actually using assignment
2148 // of the underlying object, not copy and swap.
2149 BOOST_CHECK_EQUAL(any_cast
<test_type
*>(&x
), ip
);
2152 BOOST_AUTO_TEST_CASE(test_relaxed_no_constructible_int
)
2154 typedef ::boost::mpl::vector
<
2157 constructible
<_self(int)>,
2158 move_assignable
<_self
, int>,
2161 typedef only_assign_int test_type
;
2163 typedef ::boost::mpl::map
< ::boost::mpl::pair
<_self
, test_type
> > type
;
2164 any
<test_concept
> x(binding
<test_concept
>(make_binding
<type
>()), 1);
2165 BOOST_CHECK_EQUAL(any_cast
<const test_type
&>(x
).value
, 1);
2166 test_type
* ip
= any_cast
<test_type
*>(&x
);
2168 BOOST_CHECK_EQUAL(any_cast
<const test_type
&>(x
).value
, 2);
2169 // make sure that we're actually using assignment
2170 // of the underlying object, not copy and swap.
2171 BOOST_CHECK_EQUAL(any_cast
<test_type
*>(&x
), ip
);
2174 BOOST_AUTO_TEST_CASE(test_movable_relaxed_no_assign_int
)
2176 typedef ::boost::mpl::vector
<
2180 typedef move_only_assign_int test_type
;
2181 test_type
source_x(1);
2183 any
<test_concept
> x(std::move(source_x
));
2185 BOOST_CHECK_EQUAL(any_cast
<const test_type
&>(x
).value
, 2);
2188 #ifndef BOOST_NO_CXX11_REF_QUALIFIERS
2190 BOOST_AUTO_TEST_CASE(test_move_and_copy_assignable_int
)
2192 typedef ::boost::mpl::vector
<
2195 constructible
<_self(int)>,
2196 assignable
<_self
, _self
>,
2197 move_assignable
<_self
, _self
>,
2198 assignable
<_self
, int>,
2199 move_assignable
<_self
, int>,
2202 typedef move_and_copy_assign_int test_type
;
2203 typedef ::boost::mpl::map
< ::boost::mpl::pair
<_self
, test_type
> > type
;
2205 any
<test_concept
> x(binding
<test_concept
>(make_binding
<type
>()), 1);
2206 BOOST_CHECK_EQUAL(any_cast
<const test_type
&>(x
).value
, 1);
2208 any
<test_concept
> y(binding
<test_concept
>(make_binding
<type
>()), 2);
2210 BOOST_CHECK_EQUAL(any_cast
<const test_type
&>(x
).value
, 2);
2212 any
<test_concept
> z(binding
<test_concept
>(make_binding
<type
>()), 3);
2214 BOOST_CHECK_EQUAL(any_cast
<const test_type
&>(x
).value
, 3);
2217 BOOST_CHECK_EQUAL(any_cast
<const test_type
&>(x
).value
, 4);
2220 BOOST_CHECK_EQUAL(any_cast
<const test_type
&>(x
).value
, 5);
2223 BOOST_AUTO_TEST_CASE(test_move_and_copy_assignable_copy_construct_int
)
2225 typedef ::boost::mpl::vector
<
2227 assignable
<_self
, _self
>,
2228 move_assignable
<_self
, _self
>,
2229 assignable
<_self
, int>,
2230 move_assignable
<_self
, int>,
2233 typedef move_and_copy_construct_assign_int test_type
;
2234 test_type
source_x(1);
2235 test_type
source_y(2);
2236 test_type
source_z(3);
2238 any
<test_concept
> x(source_x
);
2239 BOOST_CHECK_EQUAL(any_cast
<const test_type
&>(x
).value
, 1);
2240 test_type
* ip
= any_cast
<test_type
*>(&x
);
2242 any
<test_concept
> y(source_y
);
2244 BOOST_CHECK_EQUAL(any_cast
<const test_type
&>(x
).value
, 2);
2245 // make sure that we're actually using assignment
2246 // of the underlying object, not copy and swap.
2247 BOOST_CHECK_EQUAL(any_cast
<test_type
*>(&x
), ip
);
2249 any
<test_concept
> z(source_z
);
2251 BOOST_CHECK_EQUAL(any_cast
<const test_type
&>(x
).value
, 3);
2252 // make sure that we're actually using move-assignment
2253 // of the underlying object, not copy and swap.
2254 BOOST_CHECK_EQUAL(any_cast
<test_type
*>(&x
), ip
);
2257 BOOST_CHECK_EQUAL(any_cast
<const test_type
&>(x
).value
, 4);
2258 // make sure that we're actually using assignment
2259 // of the underlying object, not copy and swap.
2260 BOOST_CHECK_EQUAL(any_cast
<test_type
*>(&x
), ip
);
2263 BOOST_CHECK_EQUAL(any_cast
<const test_type
&>(x
).value
, 5);
2264 // make sure that we're actually using move-assignment
2265 // of the underlying object, not copy and swap.
2266 BOOST_CHECK_EQUAL(any_cast
<test_type
*>(&x
), ip
);
2269 #endif // BOOST_NO_CXX11_REF_QUALIFIERS
2271 BOOST_AUTO_TEST_CASE(test_assignable_with_conversion
)
2273 typedef ::boost::mpl::vector
<
2276 assignable
<_self
, int>,
2279 typedef move_and_copy_construct_assign_int test_type1
;
2280 typedef copy_only_assign_int test_type2
;
2281 typedef copy_only_assign_double test_type3
;
2283 test_type1
source_x(1);
2284 any
<test_concept
> x(source_x
);
2285 BOOST_CHECK_EQUAL(any_cast
<const test_type1
&>(x
).value
, 1);
2287 // assigning raw values is supported because "relaxed" is in concept.
2288 test_type2
source_y(2);
2290 BOOST_CHECK_EQUAL(any_cast
<const test_type2
&>(x
).value
, 2);
2292 // move-assigning raw values is supported because "relaxed" is in concept.
2294 BOOST_CHECK_EQUAL(any_cast
<const test_type1
&>(x
).value
, 3);
2296 // assigning int is supported because appropriate "assignable" is in concept.
2299 BOOST_CHECK_EQUAL(any_cast
<const test_type1
&>(x
).value
, 4);
2301 x
= std::move(int5
);
2302 BOOST_CHECK_EQUAL(any_cast
<const test_type1
&>(x
).value
, 5);
2304 // assigning double (which is implicitly convertible to int) is supported
2305 // because appropriate "assignable" is in concept.
2306 double double6
= 6.5;
2307 x
= double6
; // truncates value
2308 BOOST_CHECK_EQUAL(any_cast
<const test_type1
&>(x
).value
, 6);
2309 double double7
= 7.5;
2310 x
= std::move(double7
); // truncates value
2311 BOOST_CHECK_EQUAL(any_cast
<const test_type1
&>(x
).value
, 7);
2313 // assigning raw values is supported because "relaxed" is in concept.
2314 test_type3
source_z(8.5);
2316 BOOST_CHECK_EQUAL(any_cast
<const test_type3
&>(x
).value
, 8.5);
2318 // assigning double (which is implicitly convertible to int) is supported
2319 // because appropriate "assignable" is in concept.
2320 double double9
= 9.5;
2321 x
= double9
; // truncates value
2322 BOOST_CHECK_EQUAL(any_cast
<const test_type3
&>(x
).value
, 9.0);
2323 double double10
= 10.5;
2324 x
= std::move(double10
); // truncates value
2325 BOOST_CHECK_EQUAL(any_cast
<const test_type3
&>(x
).value
, 10.0);
2328 BOOST_AUTO_TEST_CASE(test_move_assignable_with_conversion
)
2330 typedef ::boost::mpl::vector
<
2333 move_assignable
<_self
, int>,
2336 typedef move_and_copy_construct_assign_int test_type1
;
2337 typedef copy_only_assign_int test_type2
;
2338 typedef copy_only_assign_double test_type3
;
2340 test_type1
source_x(1);
2341 any
<test_concept
> x(source_x
);
2342 BOOST_CHECK_EQUAL(any_cast
<const test_type1
&>(x
).value
, 1);
2344 // assigning raw values is supported because "relaxed" is in concept.
2345 test_type2
source_y(2);
2347 BOOST_CHECK_EQUAL(any_cast
<const test_type2
&>(x
).value
, 2);
2349 // move-assigning raw values is supported because "relaxed" is in concept.
2351 BOOST_CHECK_EQUAL(any_cast
<const test_type1
&>(x
).value
, 3);
2353 // move-assigning int is supported because appropriate "move_assignable" is in concept.
2355 x
= std::move(int4
);
2356 BOOST_CHECK_EQUAL(any_cast
<const test_type1
&>(x
).value
, 4);
2357 // copy-assigning int is assigning a raw_value.
2360 BOOST_CHECK_EQUAL(any_cast
<const int&>(x
), 5);
2361 x
= source_x
; // reset.
2363 // move-assigning double (which is implicitly convertible to int) is supported
2364 // because appropriate "move_assignable" is in concept.
2365 double double6
= 6.5;
2366 x
= std::move(double6
); // truncates value
2367 BOOST_CHECK_EQUAL(any_cast
<const test_type1
&>(x
).value
, 6);
2369 // assigning raw values is supported because "relaxed" is in concept.
2370 test_type3
source_z(8.5);
2372 BOOST_CHECK_EQUAL(any_cast
<const test_type3
&>(x
).value
, 8.5);
2374 // move-assigning double (which is implicitly convertible to int) is supported
2375 // because appropriate "move_assignable" is in concept.
2376 double double9
= 9.5;
2377 x
= std::move(double9
); // truncates value
2378 BOOST_CHECK_EQUAL(any_cast
<const test_type3
&>(x
).value
, 9.0);