blob: 0f68926376f24578edcc32fedcfb8cab18dc713f [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>
15// tuple(allocator_arg_t, const Alloc& a, const Types&...);
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 {
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000029 std::tuple<int> t(std::allocator_arg, A1<int>(), 3);
30 assert(std::get<0>(t) == 3);
31 }
32 {
33 assert(!alloc_first::allocator_constructed);
34 std::tuple<alloc_first> t(std::allocator_arg, A1<int>(5), alloc_first(3));
35 assert(alloc_first::allocator_constructed);
36 assert(std::get<0>(t) == alloc_first(3));
37 }
38 {
39 assert(!alloc_last::allocator_constructed);
40 std::tuple<alloc_last> t(std::allocator_arg, A1<int>(5), alloc_last(3));
41 assert(alloc_last::allocator_constructed);
42 assert(std::get<0>(t) == alloc_last(3));
43 }
44 {
45 alloc_first::allocator_constructed = false;
46 std::tuple<int, alloc_first> t(std::allocator_arg, A1<int>(5),
47 10, alloc_first(15));
48 assert(std::get<0>(t) == 10);
49 assert(alloc_first::allocator_constructed);
50 assert(std::get<1>(t) == alloc_first(15));
51 }
52 {
53 alloc_first::allocator_constructed = false;
54 alloc_last::allocator_constructed = false;
55 std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
56 A1<int>(5), 1, alloc_first(2),
57 alloc_last(3));
58 assert(std::get<0>(t) == 1);
59 assert(alloc_first::allocator_constructed);
60 assert(std::get<1>(t) == alloc_first(2));
61 assert(alloc_last::allocator_constructed);
62 assert(std::get<2>(t) == alloc_last(3));
63 }
64 {
65 alloc_first::allocator_constructed = false;
66 alloc_last::allocator_constructed = false;
67 std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
68 A2<int>(5), 1, alloc_first(2),
69 alloc_last(3));
70 assert(std::get<0>(t) == 1);
71 assert(!alloc_first::allocator_constructed);
72 assert(std::get<1>(t) == alloc_first(2));
73 assert(!alloc_last::allocator_constructed);
74 assert(std::get<2>(t) == alloc_last(3));
75 }
76}