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 {
24 // Deduct from (const OuterAlloc&).
25 {
26 typedef A1<int> OuterAlloc;
27 OuterAlloc outer(3);
28 std::scoped_allocator_adaptor a(outer);
29 ASSERT_SAME_TYPE(decltype(a), std::scoped_allocator_adaptor<OuterAlloc>);
30 }
31
32 // Deduct from (OuterAlloc&&).
33 {
34 typedef A1<int> OuterAlloc;
35 std::scoped_allocator_adaptor a(OuterAlloc(3));
36 ASSERT_SAME_TYPE(decltype(a), std::scoped_allocator_adaptor<OuterAlloc>);
37 }
38
39 // Deduct from (const OuterAlloc&, const InnerAlloc&).
40 {
41 typedef A1<int> OuterAlloc;
42 typedef A2<int> InnerAlloc;
43 OuterAlloc outer(3);
44 InnerAlloc inner(4);
45
46 std::scoped_allocator_adaptor a(outer, inner);
47 ASSERT_SAME_TYPE(decltype(a), std::scoped_allocator_adaptor<OuterAlloc, InnerAlloc>);
48 }
49
50 // Deduct from (const OuterAlloc&, const InnerAlloc1&, InnerAlloc2&&).
51 {
52 typedef A1<int> OuterAlloc;
53 typedef A2<int> InnerAlloc1;
54 typedef A2<float> InnerAlloc2;
55 OuterAlloc outer(3);
56 InnerAlloc1 inner(4);
57
58 std::scoped_allocator_adaptor a(outer, inner, InnerAlloc2(5));
59 ASSERT_SAME_TYPE(
60 decltype(a), std::scoped_allocator_adaptor<OuterAlloc, InnerAlloc1, InnerAlloc2>);
61 }
62
63 return 0;
64 }
65