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, tuple&&);
16 
17 #include <tuple>
18 #include <cassert>
19 
20 #include "../MoveOnly.h"
21 #include "allocators.h"
22 #include "../alloc_first.h"
23 #include "../alloc_last.h"
24 
25 int main()
26 {
27     {
28         typedef std::tuple<> T;
29         T t0;
30         T t(std::allocator_arg, A1<int>(), std::move(t0));
31     }
32     {
33         typedef std::tuple<MoveOnly> T;
34         T t0(MoveOnly(0));
35         T t(std::allocator_arg, A1<int>(), std::move(t0));
36         assert(std::get<0>(t) == 0);
37     }
38     {
39         typedef std::tuple<alloc_first> T;
40         T t0(1);
41         alloc_first::allocator_constructed = false;
42         T t(std::allocator_arg, A1<int>(5), std::move(t0));
43         assert(alloc_first::allocator_constructed);
44         assert(std::get<0>(t) == 1);
45     }
46     {
47         typedef std::tuple<alloc_last> T;
48         T t0(1);
49         alloc_last::allocator_constructed = false;
50         T t(std::allocator_arg, A1<int>(5), std::move(t0));
51         assert(alloc_last::allocator_constructed);
52         assert(std::get<0>(t) == 1);
53     }
54     {
55         typedef std::tuple<MoveOnly, alloc_first> T;
56         T t0(0 ,1);
57         alloc_first::allocator_constructed = false;
58         T t(std::allocator_arg, A1<int>(5), std::move(t0));
59         assert(alloc_first::allocator_constructed);
60         assert(std::get<0>(t) == 0);
61         assert(std::get<1>(t) == 1);
62     }
63     {
64         typedef std::tuple<MoveOnly, alloc_first, alloc_last> T;
65         T t0(1, 2, 3);
66         alloc_first::allocator_constructed = false;
67         alloc_last::allocator_constructed = false;
68         T t(std::allocator_arg, A1<int>(5), std::move(t0));
69         assert(alloc_first::allocator_constructed);
70         assert(alloc_last::allocator_constructed);
71         assert(std::get<0>(t) == 1);
72         assert(std::get<1>(t) == 2);
73         assert(std::get<2>(t) == 3);
74     }
75 }
76