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(const scoped_allocator_adaptor& other); |
| 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 | { |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 24 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 25 | |
| 26 | { |
| 27 | typedef std::scoped_allocator_adaptor<A1<int>> A; |
| 28 | A a1(A1<int>(3)); |
| 29 | A1<int>::copy_called = false; |
| 30 | A1<int>::move_called = false; |
| 31 | A a2 = a1; |
| 32 | assert(A1<int>::copy_called == true); |
| 33 | assert(A1<int>::move_called == false); |
| 34 | assert(a2 == a1); |
| 35 | } |
| 36 | { |
| 37 | typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A; |
| 38 | A a1(A1<int>(4), A2<int>(5)); |
| 39 | A1<int>::copy_called = false; |
| 40 | A1<int>::move_called = false; |
| 41 | A2<int>::copy_called = false; |
| 42 | A2<int>::move_called = false; |
| 43 | A a2 = a1; |
| 44 | assert(A1<int>::copy_called == true); |
| 45 | assert(A1<int>::move_called == false); |
| 46 | assert(A2<int>::copy_called == true); |
| 47 | assert(A2<int>::move_called == false); |
| 48 | assert(a2 == a1); |
| 49 | } |
| 50 | { |
| 51 | typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A; |
| 52 | A a1(A1<int>(4), A2<int>(5), A3<int>(6)); |
| 53 | A1<int>::copy_called = false; |
| 54 | A1<int>::move_called = false; |
| 55 | A2<int>::copy_called = false; |
| 56 | A2<int>::move_called = false; |
| 57 | A3<int>::copy_called = false; |
| 58 | A3<int>::move_called = false; |
| 59 | A a2 = a1; |
| 60 | assert(A1<int>::copy_called == true); |
| 61 | assert(A1<int>::move_called == false); |
| 62 | assert(A2<int>::copy_called == true); |
| 63 | assert(A2<int>::move_called == false); |
| 64 | assert(A3<int>::copy_called == true); |
| 65 | assert(A3<int>::move_called == false); |
| 66 | assert(a2 == a1); |
| 67 | } |
| 68 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 69 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 70 | } |