convert_copy.pass.cpp revision f5256e16dfc425c1d466f6308d4026d529ce9e0b
1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <tuple> 11 12// template <class... Types> class tuple; 13 14// template <class... UTypes> tuple(const tuple<UTypes...>& u); 15 16#include <tuple> 17#include <string> 18#include <cassert> 19 20struct B 21{ 22 int id_; 23 24 explicit B(int i) : id_(i) {} 25}; 26 27struct D 28 : B 29{ 30 explicit D(int i) : B(i) {} 31}; 32 33int main() 34{ 35 { 36 typedef std::tuple<double> T0; 37 typedef std::tuple<int> T1; 38 T0 t0(2.5); 39 T1 t1 = t0; 40 assert(std::get<0>(t1) == 2); 41 } 42 { 43 typedef std::tuple<double, char> T0; 44 typedef std::tuple<int, int> T1; 45 T0 t0(2.5, 'a'); 46 T1 t1 = t0; 47 assert(std::get<0>(t1) == 2); 48 assert(std::get<1>(t1) == int('a')); 49 } 50 { 51 typedef std::tuple<double, char, D> T0; 52 typedef std::tuple<int, int, B> T1; 53 T0 t0(2.5, 'a', D(3)); 54 T1 t1 = t0; 55 assert(std::get<0>(t1) == 2); 56 assert(std::get<1>(t1) == int('a')); 57 assert(std::get<2>(t1).id_ == 3); 58 } 59 { 60 D d(3); 61 typedef std::tuple<double, char, D&> T0; 62 typedef std::tuple<int, int, B&> T1; 63 T0 t0(2.5, 'a', d); 64 T1 t1 = t0; 65 d.id_ = 2; 66 assert(std::get<0>(t1) == 2); 67 assert(std::get<1>(t1) == int('a')); 68 assert(std::get<2>(t1).id_ == 2); 69 } 70} 71