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, class... UTypes>
15//   tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&);
16
17// UNSUPPORTED: c++98, c++03
18
19#include <tuple>
20#include <cassert>
21
22#include "allocators.h"
23#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    }
69}
70