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 <size_t I, class... Types>
15//   typename tuple_element<I, tuple<Types...> >::type const&
16//   get(const tuple<Types...>& t);
17
18#include <tuple>
19#include <string>
20#include <cassert>
21
22struct Empty {};
23
24int main()
25{
26    {
27        typedef std::tuple<int> T;
28        const T t(3);
29        assert(std::get<0>(t) == 3);
30    }
31    {
32        typedef std::tuple<std::string, int> T;
33        const T t("high", 5);
34        assert(std::get<0>(t) == "high");
35        assert(std::get<1>(t) == 5);
36    }
37#if _LIBCPP_STD_VER > 11
38    {
39        typedef std::tuple<double, int> T;
40        constexpr T t(2.718, 5);
41        static_assert(std::get<0>(t) == 2.718, "");
42        static_assert(std::get<1>(t) == 5, "");
43    }
44    {
45        typedef std::tuple<Empty> T;
46        constexpr T t{Empty()};
47        constexpr Empty e = std::get<0>(t);
48    }
49#endif
50    {
51        typedef std::tuple<double&, std::string, int> T;
52        double d = 1.5;
53        const T t(d, "high", 5);
54        assert(std::get<0>(t) == 1.5);
55        assert(std::get<1>(t) == "high");
56        assert(std::get<2>(t) == 5);
57        std::get<0>(t) = 2.5;
58        assert(std::get<0>(t) == 2.5);
59        assert(std::get<1>(t) == "high");
60        assert(std::get<2>(t) == 5);
61        assert(d == 2.5);
62    }
63}
64