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// scoped_allocator_adaptor();
17
18#include <scoped_allocator>
19#include <cassert>
20
21#include "test_macros.h"
22#include "allocators.h"
23
24int main(int, char**) {
25 {
26 typedef std::scoped_allocator_adaptor<A1<int>> A;
27 A a;
28 assert(a.outer_allocator() == A1<int>());
29 assert(a.inner_allocator() == a);
30 assert(A1<int>::copy_called == false);
31 assert(A1<int>::move_called == false);
32 }
33 {
34 typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
35 A a;
36 assert(a.outer_allocator() == A1<int>());
37 assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>());
38 assert(A1<int>::copy_called == false);
39 assert(A1<int>::move_called == false);
40 assert(A2<int>::copy_called == false);
41 assert(A2<int>::move_called == false);
42 }
43 {
44 typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
45 A a;
46 assert(a.outer_allocator() == A1<int>());
47 assert((a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>, A3<int>>()));
48 assert(A1<int>::copy_called == false);
49 assert(A1<int>::move_called == false);
50 assert(A2<int>::copy_called == false);
51 assert(A2<int>::move_called == false);
52 assert(A3<int>::copy_called == false);
53 assert(A3<int>::move_called == false);
54 }
55
56 return 0;
57}
58

source code of libcxx/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/default.pass.cpp