1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <tuple>
11
12 // template <class... Types> class tuple;
13
14 // template <class Alloc>
15 // tuple(allocator_arg_t, const Alloc& a);
16
17 #include <tuple>
18 #include <cassert>
19
20 #include "DefaultOnly.h"
21 #include "allocators.h"
22 #include "../alloc_first.h"
23 #include "../alloc_last.h"
24
main()25 int main()
26 {
27 {
28 std::tuple<> t(std::allocator_arg, A1<int>());
29 }
30 {
31 std::tuple<int> t(std::allocator_arg, A1<int>());
32 assert(std::get<0>(t) == 0);
33 }
34 {
35 std::tuple<DefaultOnly> t(std::allocator_arg, A1<int>());
36 assert(std::get<0>(t) == DefaultOnly());
37 }
38 {
39 assert(!alloc_first::allocator_constructed);
40 std::tuple<alloc_first> t(std::allocator_arg, A1<int>(5));
41 assert(alloc_first::allocator_constructed);
42 assert(std::get<0>(t) == alloc_first());
43 }
44 {
45 assert(!alloc_last::allocator_constructed);
46 std::tuple<alloc_last> t(std::allocator_arg, A1<int>(5));
47 assert(alloc_last::allocator_constructed);
48 assert(std::get<0>(t) == alloc_last());
49 }
50 {
51 alloc_first::allocator_constructed = false;
52 std::tuple<DefaultOnly, alloc_first> t(std::allocator_arg, A1<int>(5));
53 assert(std::get<0>(t) == DefaultOnly());
54 assert(alloc_first::allocator_constructed);
55 assert(std::get<1>(t) == alloc_first());
56 }
57 {
58 alloc_first::allocator_constructed = false;
59 alloc_last::allocator_constructed = false;
60 std::tuple<DefaultOnly, alloc_first, alloc_last> t(std::allocator_arg,
61 A1<int>(5));
62 assert(std::get<0>(t) == DefaultOnly());
63 assert(alloc_first::allocator_constructed);
64 assert(std::get<1>(t) == alloc_first());
65 assert(alloc_last::allocator_constructed);
66 assert(std::get<2>(t) == alloc_last());
67 }
68 {
69 alloc_first::allocator_constructed = false;
70 alloc_last::allocator_constructed = false;
71 std::tuple<DefaultOnly, alloc_first, alloc_last> t(std::allocator_arg,
72 A2<int>(5));
73 assert(std::get<0>(t) == DefaultOnly());
74 assert(!alloc_first::allocator_constructed);
75 assert(std::get<1>(t) == alloc_first());
76 assert(!alloc_last::allocator_constructed);
77 assert(std::get<2>(t) == alloc_last());
78 }
79 }
80