get_non_const.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
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 <size_t I, class... Types> 15// typename tuple_element<I, tuple<Types...> >::type& 16// get(tuple<Types...>& t); 17 18#include <tuple> 19#include <string> 20#include <cassert> 21 22int main() 23{ 24 { 25 typedef std::tuple<int> T; 26 T t(3); 27 assert(std::get<0>(t) == 3); 28 std::get<0>(t) = 2; 29 assert(std::get<0>(t) == 2); 30 } 31 { 32 typedef std::tuple<std::string, int> T; 33 T t("high", 5); 34 assert(std::get<0>(t) == "high"); 35 assert(std::get<1>(t) == 5); 36 std::get<0>(t) = "four"; 37 std::get<1>(t) = 4; 38 assert(std::get<0>(t) == "four"); 39 assert(std::get<1>(t) == 4); 40 } 41 { 42 typedef std::tuple<double&, std::string, int> T; 43 double d = 1.5; 44 T t(d, "high", 5); 45 assert(std::get<0>(t) == 1.5); 46 assert(std::get<1>(t) == "high"); 47 assert(std::get<2>(t) == 5); 48 std::get<0>(t) = 2.5; 49 std::get<1>(t) = "four"; 50 std::get<2>(t) = 4; 51 assert(std::get<0>(t) == 2.5); 52 assert(std::get<1>(t) == "four"); 53 assert(std::get<2>(t) == 4); 54 assert(d == 2.5); 55 } 56} 57