• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <tuple>
10 
11 // template <class... Types> class tuple;
12 
13 // template<class... Types>
14 //   tuple<VTypes...> make_tuple(Types&&... t);
15 
16 // UNSUPPORTED: c++03
17 
18 #include <tuple>
19 #include <functional>
20 #include <cassert>
21 
22 #include "test_macros.h"
23 
main(int,char **)24 int main(int, char**)
25 {
26     {
27         int i = 0;
28         float j = 0;
29         std::tuple<int, int&, float&> t = std::make_tuple(1, std::ref(i),
30                                                           std::ref(j));
31         assert(std::get<0>(t) == 1);
32         assert(std::get<1>(t) == 0);
33         assert(std::get<2>(t) == 0);
34         i = 2;
35         j = 3.5;
36         assert(std::get<0>(t) == 1);
37         assert(std::get<1>(t) == 2);
38         assert(std::get<2>(t) == 3.5);
39         std::get<1>(t) = 0;
40         std::get<2>(t) = 0;
41         assert(i == 0);
42         assert(j == 0);
43     }
44 #if TEST_STD_VER > 11
45     {
46         constexpr auto t1 = std::make_tuple(0, 1, 3.14);
47         constexpr int i1 = std::get<1>(t1);
48         constexpr double d1 = std::get<2>(t1);
49         static_assert (i1 == 1, "" );
50         static_assert (d1 == 3.14, "" );
51     }
52 #endif
53 
54   return 0;
55 }
56