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