1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: c++03
10 
11 // <memory>
12 
13 // template <class OuterAlloc, class... InnerAllocs>
14 //   class scoped_allocator_adaptor
15 
16 // template <class OuterA2>
17 //   scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2,
18 //                                                           InnerAllocs...>& other);
19 
20 #include <scoped_allocator>
21 #include <cassert>
22 
23 #include "test_macros.h"
24 #include "allocators.h"
25 
main(int,char **)26 int main(int, char**) {
27   {
28     typedef std::scoped_allocator_adaptor<A1<double>> B;
29     typedef std::scoped_allocator_adaptor<A1<int>> A;
30     B a1(A1<int>(3));
31     A1<int>::copy_called = false;
32     A1<int>::move_called = false;
33     A a2                 = a1;
34     assert(A1<int>::copy_called == true);
35     assert(a2 == a1);
36   }
37   {
38     typedef std::scoped_allocator_adaptor<A1<double>, A2<int>> B;
39     typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
40     B a1(A1<int>(4), A2<int>(5));
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     A a2                 = a1;
46     assert(A1<int>::copy_called == true);
47     assert(A2<int>::copy_called == true);
48     assert(a2 == a1);
49   }
50   {
51     typedef std::scoped_allocator_adaptor<A1<double>, A2<int>, A3<int>> B;
52     typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
53     B a1(A1<int>(4), A2<int>(5), A3<int>(6));
54     A1<int>::copy_called = false;
55     A1<int>::move_called = false;
56     A2<int>::copy_called = false;
57     A2<int>::move_called = false;
58     A3<int>::copy_called = false;
59     A3<int>::move_called = false;
60     A a2                 = a1;
61     assert(A1<int>::copy_called == true);
62     assert(A2<int>::copy_called == true);
63     assert(A3<int>::copy_called == true);
64     assert(a2 == a1);
65   }
66 
67   return 0;
68 }
69