get_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 const& 16// get(const 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 const T t(3); 27 assert(std::get<0>(t) == 3); 28 } 29 { 30 typedef std::tuple<std::string, int> T; 31 const T t("high", 5); 32 assert(std::get<0>(t) == "high"); 33 assert(std::get<1>(t) == 5); 34 } 35 { 36 typedef std::tuple<double&, std::string, int> T; 37 double d = 1.5; 38 const T t(d, "high", 5); 39 assert(std::get<0>(t) == 1.5); 40 assert(std::get<1>(t) == "high"); 41 assert(std::get<2>(t) == 5); 42 std::get<0>(t) = 2.5; 43 assert(std::get<0>(t) == 2.5); 44 assert(std::get<1>(t) == "high"); 45 assert(std::get<2>(t) == 5); 46 assert(d == 2.5); 47 } 48} 49