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