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 int main() 24 { 25 { 26 int i = 0; 27 float j = 0; 28 std::tuple<int, int&, float&> t = std::make_tuple(1, std::ref(i), 29 std::ref(j)); 30 assert(std::get<0>(t) == 1); 31 assert(std::get<1>(t) == 0); 32 assert(std::get<2>(t) == 0); 33 i = 2; 34 j = 3.5; 35 assert(std::get<0>(t) == 1); 36 assert(std::get<1>(t) == 2); 37 assert(std::get<2>(t) == 3.5); 38 std::get<1>(t) = 0; 39 std::get<2>(t) = 0; 40 assert(i == 0); 41 assert(j == 0); 42 } 43 #if _LIBCPP_STD_VER > 11 44 { 45 constexpr auto t1 = std::make_tuple(0, 1, 3.14); 46 constexpr int i1 = std::get<1>(t1); 47 constexpr double d1 = std::get<2>(t1); 48 static_assert (i1 == 1, "" ); 49 static_assert (d1 == 3.14, "" ); 50 } 51 #endif 52 } 53