blob: fd953f843405f44dfddfc27f1b3cfd60f2eb929c [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnant5b08a8a2010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnant3e519522010-05-11 19:42:16 +00004//
Howard Hinnant412dbeb2010-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 Hinnant3e519522010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <tuple>
11
12// template <class... Types> class tuple;
13
14// tuple(const tuple& u) = default;
15
16#include <tuple>
17#include <string>
18#include <cassert>
19
Marshall Clow75eff742013-07-22 16:02:19 +000020struct Empty {};
21
Howard Hinnant3e519522010-05-11 19:42:16 +000022int main()
23{
24 {
25 typedef std::tuple<> T;
26 T t0;
27 T t = t0;
28 }
29 {
30 typedef std::tuple<int> T;
31 T t0(2);
32 T t = t0;
33 assert(std::get<0>(t) == 2);
34 }
35 {
36 typedef std::tuple<int, char> T;
37 T t0(2, 'a');
38 T t = t0;
39 assert(std::get<0>(t) == 2);
40 assert(std::get<1>(t) == 'a');
41 }
42 {
43 typedef std::tuple<int, char, std::string> T;
Howard Hinnantfa8df7d2012-02-15 20:13:52 +000044 const T t0(2, 'a', "some text");
Howard Hinnant3e519522010-05-11 19:42:16 +000045 T t = t0;
46 assert(std::get<0>(t) == 2);
47 assert(std::get<1>(t) == 'a');
48 assert(std::get<2>(t) == "some text");
49 }
Marshall Clow75eff742013-07-22 16:02:19 +000050#if _LIBCPP_STD_VER > 11
51 {
52 typedef std::tuple<int> T;
53 constexpr T t0(2);
54 constexpr T t = t0;
55 static_assert(std::get<0>(t) == 2, "");
56 }
57 {
58 typedef std::tuple<Empty> T;
59 constexpr T t0;
60 constexpr T t = t0;
61 }
62#endif
Howard Hinnant3e519522010-05-11 19:42:16 +000063}