Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <memory> |
| 11 | |
| 12 | // template <class OuterAlloc, class... InnerAllocs> |
| 13 | // class scoped_allocator_adaptor |
| 14 | |
| 15 | // scoped_allocator_adaptor select_on_container_copy_construction() const; |
| 16 | |
Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 17 | #include <scoped_allocator> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 18 | #include <cassert> |
| 19 | |
| 20 | #include "../allocators.h" |
| 21 | |
| 22 | int main() |
| 23 | { |
| 24 | #ifdef _LIBCPP_MOVE |
| 25 | |
| 26 | { |
| 27 | typedef std::scoped_allocator_adaptor<A1<int>> A; |
| 28 | A a1(A1<int>(3)); |
| 29 | assert(a1.outer_allocator().id() == 3); |
| 30 | A a2 = std::allocator_traits<A>::select_on_container_copy_construction(a1); |
| 31 | assert(a2.outer_allocator().id() == 3); |
| 32 | } |
| 33 | |
| 34 | { |
| 35 | typedef std::scoped_allocator_adaptor<A3<int>> A; |
| 36 | A a1(A3<int>(3)); |
| 37 | assert(a1.outer_allocator().id() == 3); |
| 38 | A a2 = std::allocator_traits<A>::select_on_container_copy_construction(a1); |
| 39 | assert(a2.outer_allocator().id() == -1); |
| 40 | } |
| 41 | |
| 42 | { |
| 43 | typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A; |
| 44 | A a1(A1<int>(1), A2<int>(2), A3<int>(3)); |
| 45 | assert(a1.outer_allocator().id() == 1); |
| 46 | assert(a1.inner_allocator().outer_allocator().id() == 2); |
| 47 | assert(a1.inner_allocator().inner_allocator().outer_allocator().id() == 3); |
| 48 | A a2 = std::allocator_traits<A>::select_on_container_copy_construction(a1); |
| 49 | assert(a2.outer_allocator().id() == 1); |
| 50 | assert(a2.inner_allocator().outer_allocator().id() == 2); |
| 51 | assert(a2.inner_allocator().inner_allocator().outer_allocator().id() == -1); |
| 52 | } |
| 53 | |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 54 | #endif // _LIBCPP_MOVE |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 55 | } |