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