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, c++11, c++14
10
11 // <scoped_allocator>
12
13 // template<class _OuterAlloc, class... _InnerAllocs>
14 // scoped_allocator_adaptor(_OuterAlloc, _InnerAllocs...)
15 // -> scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>;
16
17 #include <scoped_allocator>
18
19 #include "test_macros.h"
20 #include "allocators.h"
21
main(int,char **)22 int main(int, char**) {
23 // Deduct from (const OuterAlloc&).
24 {
25 typedef A1<int> OuterAlloc;
26 OuterAlloc outer(3);
27 std::scoped_allocator_adaptor a(outer);
28 ASSERT_SAME_TYPE(decltype(a), std::scoped_allocator_adaptor<OuterAlloc>);
29 }
30
31 // Deduct from (OuterAlloc&&).
32 {
33 typedef A1<int> OuterAlloc;
34 std::scoped_allocator_adaptor a(OuterAlloc(3));
35 ASSERT_SAME_TYPE(decltype(a), std::scoped_allocator_adaptor<OuterAlloc>);
36 }
37
38 // Deduct from (const OuterAlloc&, const InnerAlloc&).
39 {
40 typedef A1<int> OuterAlloc;
41 typedef A2<int> InnerAlloc;
42 OuterAlloc outer(3);
43 InnerAlloc inner(4);
44
45 std::scoped_allocator_adaptor a(outer, inner);
46 ASSERT_SAME_TYPE(decltype(a), std::scoped_allocator_adaptor<OuterAlloc, InnerAlloc>);
47 }
48
49 // Deduct from (const OuterAlloc&, const InnerAlloc1&, InnerAlloc2&&).
50 {
51 typedef A1<int> OuterAlloc;
52 typedef A2<int> InnerAlloc1;
53 typedef A2<float> InnerAlloc2;
54 OuterAlloc outer(3);
55 InnerAlloc1 inner(4);
56
57 std::scoped_allocator_adaptor a(outer, inner, InnerAlloc2(5));
58 ASSERT_SAME_TYPE(decltype(a), std::scoped_allocator_adaptor<OuterAlloc, InnerAlloc1, InnerAlloc2>);
59 }
60
61 return 0;
62 }
63