xref: /llvm-project/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp (revision 7a7d4cdb9086131d3a79695d1c4b6a1abe62c638)
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... Types>
15 //   tuple<Types&...> tie(Types&... t);
16 
17 // UNSUPPORTED: c++98, c++03
18 
19 #include <tuple>
20 #include <string>
21 #include <cassert>
22 
23 #include "test_macros.h"
24 
25 int main()
26 {
27     {
28         int i = 0;
29         std::string s;
30         std::tie(i, std::ignore, s) = std::make_tuple(42, 3.14, "C++");
31         assert(i == 42);
32         assert(s == "C++");
33     }
34 #if TEST_STD_VER > 11
35     {
36         static constexpr int i = 42;
37         static constexpr double f = 1.1;
38         constexpr std::tuple<const int &, const double &> t = std::tie(i, f);
39         static_assert ( std::get<0>(t) == 42, "" );
40         static_assert ( std::get<1>(t) == 1.1, "" );
41     }
42 #endif
43 }
44