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 // <tuple>
10
11 // template <class... Types> class tuple;
12
13 // template <class Alloc>
14 // tuple(allocator_arg_t, const Alloc& a, const tuple&);
15
16 // UNSUPPORTED: c++03
17
18 #include <tuple>
19 #include <cassert>
20
21 #include "test_macros.h"
22 #include "allocators.h"
23 #include "../alloc_first.h"
24 #include "../alloc_last.h"
25
main(int,char **)26 int main(int, char**)
27 {
28 {
29 typedef std::tuple<> T;
30 T t0;
31 T t(std::allocator_arg, A1<int>(), t0);
32 }
33 {
34 typedef std::tuple<int> T;
35 T t0(2);
36 T t(std::allocator_arg, A1<int>(), t0);
37 assert(std::get<0>(t) == 2);
38 }
39 {
40 typedef std::tuple<alloc_first> T;
41 T t0(2);
42 alloc_first::allocator_constructed = false;
43 T t(std::allocator_arg, A1<int>(5), t0);
44 assert(alloc_first::allocator_constructed);
45 assert(std::get<0>(t) == 2);
46 }
47 {
48 typedef std::tuple<alloc_last> T;
49 T t0(2);
50 alloc_last::allocator_constructed = false;
51 T t(std::allocator_arg, A1<int>(5), t0);
52 assert(alloc_last::allocator_constructed);
53 assert(std::get<0>(t) == 2);
54 }
55 // testing extensions
56 #ifdef _LIBCPP_VERSION
57 {
58 typedef std::tuple<alloc_first, alloc_last> T;
59 T t0(2, 3);
60 alloc_first::allocator_constructed = false;
61 alloc_last::allocator_constructed = false;
62 T t(std::allocator_arg, A1<int>(5), t0);
63 assert(alloc_first::allocator_constructed);
64 assert(alloc_last::allocator_constructed);
65 assert(std::get<0>(t) == 2);
66 assert(std::get<1>(t) == 3);
67 }
68 {
69 typedef std::tuple<int, alloc_first, alloc_last> T;
70 T t0(1, 2, 3);
71 alloc_first::allocator_constructed = false;
72 alloc_last::allocator_constructed = false;
73 T t(std::allocator_arg, A1<int>(5), t0);
74 assert(alloc_first::allocator_constructed);
75 assert(alloc_last::allocator_constructed);
76 assert(std::get<0>(t) == 1);
77 assert(std::get<1>(t) == 2);
78 assert(std::get<2>(t) == 3);
79 }
80 #endif
81
82 return 0;
83 }
84