blob: 0dc479c246c9e31b9592acac1ee316f990d8c0c3 [file] [log] [blame]
Marshall Clow8997b872015-10-25 19:53:29 +00001//===----------------------------------------------------------------------===//
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
23int 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 = std::move(a1);
33 assert(A1<int>::copy_called == false);
34 assert(A1<int>::move_called == true);
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 = std::move(a1);
46 assert(A1<int>::copy_called == false);
47 assert(A1<int>::move_called == true);
48 assert(A2<int>::copy_called == false);
49 assert(A2<int>::move_called == true);
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 = std::move(a1);
63 assert(A1<int>::copy_called == false);
64 assert(A1<int>::move_called == true);
65 assert(A2<int>::copy_called == false);
66 assert(A2<int>::move_called == true);
67 assert(A3<int>::copy_called == false);
68 assert(A3<int>::move_called == true);
69 assert(aN == a1);
70 }
71#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
72}