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... UTypes> 15 // tuple& operator=(const tuple<UTypes...>& u); 16 17 #include <tuple> 18 #include <string> 19 #include <cassert> 20 21 struct B 22 { 23 int id_; 24 25 explicit B(int i = 0) : id_(i) {} 26 }; 27 28 struct D 29 : B 30 { 31 explicit D(int i = 0) : B(i) {} 32 }; 33 34 int main() 35 { 36 { 37 typedef std::tuple<double> T0; 38 typedef std::tuple<int> T1; 39 T0 t0(2.5); 40 T1 t1; 41 t1 = t0; 42 assert(std::get<0>(t1) == 2); 43 } 44 { 45 typedef std::tuple<double, char> T0; 46 typedef std::tuple<int, int> T1; 47 T0 t0(2.5, 'a'); 48 T1 t1; 49 t1 = t0; 50 assert(std::get<0>(t1) == 2); 51 assert(std::get<1>(t1) == int('a')); 52 } 53 { 54 typedef std::tuple<double, char, D> T0; 55 typedef std::tuple<int, int, B> T1; 56 T0 t0(2.5, 'a', D(3)); 57 T1 t1; 58 t1 = t0; 59 assert(std::get<0>(t1) == 2); 60 assert(std::get<1>(t1) == int('a')); 61 assert(std::get<2>(t1).id_ == 3); 62 } 63 { 64 D d(3); 65 D d2(2); 66 typedef std::tuple<double, char, D&> T0; 67 typedef std::tuple<int, int, B&> T1; 68 T0 t0(2.5, 'a', d2); 69 T1 t1(1.5, 'b', d); 70 t1 = t0; 71 assert(std::get<0>(t1) == 2); 72 assert(std::get<1>(t1) == int('a')); 73 assert(std::get<2>(t1).id_ == 2); 74 } 75 } 76