//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // template // class scoped_allocator_adaptor // template // scoped_allocator_adaptor(OuterA2&& outerAlloc, // const InnerAllocs& ...innerAllocs); #include #include #include "../allocators.h" int main() { #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::scoped_allocator_adaptor> A; A1 a3(3); A a(a3); assert(a.outer_allocator() == A1(3)); assert(a.inner_allocator() == a); assert(A1::copy_called == true); assert(A1::move_called == false); } A1::copy_called = false; { typedef std::scoped_allocator_adaptor> A; A a(A1(3)); assert(a.outer_allocator() == A1(3)); assert(a.inner_allocator() == a); assert(A1::copy_called == false); assert(A1::move_called == true); } A1::move_called = false; { typedef std::scoped_allocator_adaptor, A2> A; A1 a4(4); A a(a4, A2(5)); assert(A1::copy_called == true); assert(A1::move_called == false); assert(A2::copy_called == true); assert(A2::move_called == false); assert(a.outer_allocator() == A1(4)); assert(a.inner_allocator() == std::scoped_allocator_adaptor>(A2(5))); } A1::copy_called = false; A1::move_called = false; A2::copy_called = false; A2::move_called = false; { typedef std::scoped_allocator_adaptor, A2> A; A a(A1(4), A2(5)); assert(A1::copy_called == false); assert(A1::move_called == true); assert(A2::copy_called == true); assert(A2::move_called == false); assert(a.outer_allocator() == A1(4)); assert(a.inner_allocator() == std::scoped_allocator_adaptor>(A2(5))); } A1::copy_called = false; A1::move_called = false; A2::copy_called = false; A2::move_called = false; A1::move_called = false; { typedef std::scoped_allocator_adaptor, A2, A3> A; A1 a4(4); A a(a4, A2(5), A3(6)); assert(A1::copy_called == true); assert(A1::move_called == false); assert(A2::copy_called == true); assert(A2::move_called == false); assert(A3::copy_called == true); assert(A3::move_called == false); assert(a.outer_allocator() == A1(4)); assert((a.inner_allocator() == std::scoped_allocator_adaptor, A3>(A2(5), A3(6)))); } A1::copy_called = false; A1::move_called = false; A2::copy_called = false; A2::move_called = false; A3::copy_called = false; A3::move_called = false; { typedef std::scoped_allocator_adaptor, A2, A3> A; A a(A1(4), A2(5), A3(6)); assert(A1::copy_called == false); assert(A1::move_called == true); assert(A2::copy_called == true); assert(A2::move_called == false); assert(A3::copy_called == true); assert(A3::move_called == false); assert(a.outer_allocator() == A1(4)); assert((a.inner_allocator() == std::scoped_allocator_adaptor, A3>(A2(5), A3(6)))); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES }