Marshall Clow | 8997b87 | 2015-10-25 19:53:29 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. 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& operator=(const scoped_allocator_adaptor& other); |
| 16 | |
| 17 | |
| 18 | #include <scoped_allocator> |
| 19 | #include <cassert> |
| 20 | |
| 21 | #include "allocators.h" |
| 22 | |
| 23 | int main() |
| 24 | { |
| 25 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 26 | { |
| 27 | typedef std::scoped_allocator_adaptor<A1<int>> A; |
| 28 | A a1(A1<int>(3)); |
| 29 | A aN; |
| 30 | A1<int>::copy_called = false; |
| 31 | A1<int>::move_called = false; |
| 32 | aN = a1; |
| 33 | assert(A1<int>::copy_called == true); |
| 34 | assert(A1<int>::move_called == false); |
| 35 | assert(aN == a1); |
| 36 | } |
| 37 | { |
| 38 | typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A; |
| 39 | A a1(A1<int>(4), A2<int>(5)); |
| 40 | A aN; |
| 41 | A1<int>::copy_called = false; |
| 42 | A1<int>::move_called = false; |
| 43 | A2<int>::copy_called = false; |
| 44 | A2<int>::move_called = false; |
| 45 | aN = a1; |
| 46 | assert(A1<int>::copy_called == true); |
| 47 | assert(A1<int>::move_called == false); |
| 48 | assert(A2<int>::copy_called == true); |
| 49 | assert(A2<int>::move_called == false); |
| 50 | assert(aN == a1); |
| 51 | } |
| 52 | { |
| 53 | typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A; |
| 54 | A a1(A1<int>(4), A2<int>(5), A3<int>(6)); |
| 55 | A aN; |
| 56 | A1<int>::copy_called = false; |
| 57 | A1<int>::move_called = false; |
| 58 | A2<int>::copy_called = false; |
| 59 | A2<int>::move_called = false; |
| 60 | A3<int>::copy_called = false; |
| 61 | A3<int>::move_called = false; |
| 62 | aN = a1; |
| 63 | assert(A1<int>::copy_called == true); |
| 64 | assert(A1<int>::move_called == false); |
| 65 | assert(A2<int>::copy_called == true); |
| 66 | assert(A2<int>::move_called == false); |
| 67 | assert(A3<int>::copy_called == true); |
| 68 | assert(A3<int>::move_called == false); |
| 69 | assert(aN == a1); |
| 70 | } |
| 71 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 72 | } |