blob: 8acfde7a98eb102e340c1d84cd5ff5098fd8b36f [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <tuple>
11
12// template <class... Types> class tuple;
13
14// template <class Alloc, class... UTypes>
15// tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&);
16
Eric Fiselierf0630522015-02-19 02:10:42 +000017// UNSUPPORTED: c++98, c++03
18
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000019#include <tuple>
20#include <cassert>
21
Marshall Clowebedffd2013-12-02 18:08:31 +000022#include "allocators.h"
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000023#include "../alloc_first.h"
24#include "../alloc_last.h"
25
26int main()
27{
28 {
29 typedef std::tuple<double> T0;
30 typedef std::tuple<int> T1;
31 T0 t0(2.5);
32 T1 t1(std::allocator_arg, A1<int>(), t0);
33 assert(std::get<0>(t1) == 2);
34 }
35 {
36 typedef std::tuple<int> T0;
37 typedef std::tuple<alloc_first> T1;
38 T0 t0(2);
39 alloc_first::allocator_constructed = false;
40 T1 t1(std::allocator_arg, A1<int>(5), t0);
41 assert(alloc_first::allocator_constructed);
42 assert(std::get<0>(t1) == 2);
43 }
44 {
45 typedef std::tuple<int, int> T0;
46 typedef std::tuple<alloc_first, alloc_last> T1;
47 T0 t0(2, 3);
48 alloc_first::allocator_constructed = false;
49 alloc_last::allocator_constructed = false;
50 T1 t1(std::allocator_arg, A1<int>(5), t0);
51 assert(alloc_first::allocator_constructed);
52 assert(alloc_last::allocator_constructed);
53 assert(std::get<0>(t1) == 2);
54 assert(std::get<1>(t1) == 3);
55 }
56 {
57 typedef std::tuple<double, int, int> T0;
58 typedef std::tuple<int, alloc_first, alloc_last> T1;
59 T0 t0(1.5, 2, 3);
60 alloc_first::allocator_constructed = false;
61 alloc_last::allocator_constructed = false;
62 T1 t1(std::allocator_arg, A1<int>(5), t0);
63 assert(alloc_first::allocator_constructed);
64 assert(alloc_last::allocator_constructed);
65 assert(std::get<0>(t1) == 1);
66 assert(std::get<1>(t1) == 2);
67 assert(std::get<2>(t1) == 3);
68 }
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000069}