• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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<VTypes...> make_tuple(Types&&... t);
16 
17 // UNSUPPORTED: c++98, c++03
18 
19 #include <tuple>
20 #include <functional>
21 #include <cassert>
22 
23 #include "test_macros.h"
24 
main()25 int main()
26 {
27     {
28         int i = 0;
29         float j = 0;
30         std::tuple<int, int&, float&> t = std::make_tuple(1, std::ref(i),
31                                                           std::ref(j));
32         assert(std::get<0>(t) == 1);
33         assert(std::get<1>(t) == 0);
34         assert(std::get<2>(t) == 0);
35         i = 2;
36         j = 3.5;
37         assert(std::get<0>(t) == 1);
38         assert(std::get<1>(t) == 2);
39         assert(std::get<2>(t) == 3.5);
40         std::get<1>(t) = 0;
41         std::get<2>(t) = 0;
42         assert(i == 0);
43         assert(j == 0);
44     }
45 #if TEST_STD_VER > 11
46     {
47         constexpr auto t1 = std::make_tuple(0, 1, 3.14);
48         constexpr int i1 = std::get<1>(t1);
49         constexpr double d1 = std::get<2>(t1);
50         static_assert (i1 == 1, "" );
51         static_assert (d1 == 3.14, "" );
52     }
53 #endif
54 }
55