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 Alloc> 15 // tuple(allocator_arg_t, const Alloc& a, const tuple&); 16 17 #include <tuple> 18 #include <cassert> 19 20 #include "../allocators.h" 21 #include "../alloc_first.h" 22 #include "../alloc_last.h" 23 24 int main() 25 { 26 { 27 typedef std::tuple<> T; 28 T t0; 29 T t(std::allocator_arg, A1<int>(), t0); 30 } 31 { 32 typedef std::tuple<int> T; 33 T t0(2); 34 T t(std::allocator_arg, A1<int>(), t0); 35 assert(std::get<0>(t) == 2); 36 } 37 { 38 typedef std::tuple<alloc_first> T; 39 T t0(2); 40 alloc_first::allocator_constructed = false; 41 T t(std::allocator_arg, A1<int>(5), t0); 42 assert(alloc_first::allocator_constructed); 43 assert(std::get<0>(t) == 2); 44 } 45 { 46 typedef std::tuple<alloc_last> T; 47 T t0(2); 48 alloc_last::allocator_constructed = false; 49 T t(std::allocator_arg, A1<int>(5), t0); 50 assert(alloc_last::allocator_constructed); 51 assert(std::get<0>(t) == 2); 52 } 53 { 54 typedef std::tuple<alloc_first, alloc_last> T; 55 T t0(2, 3); 56 alloc_first::allocator_constructed = false; 57 alloc_last::allocator_constructed = false; 58 T t(std::allocator_arg, A1<int>(5), t0); 59 assert(alloc_first::allocator_constructed); 60 assert(alloc_last::allocator_constructed); 61 assert(std::get<0>(t) == 2); 62 assert(std::get<1>(t) == 3); 63 } 64 { 65 typedef std::tuple<int, alloc_first, alloc_last> T; 66 T t0(1, 2, 3); 67 alloc_first::allocator_constructed = false; 68 alloc_last::allocator_constructed = false; 69 T t(std::allocator_arg, A1<int>(5), t0); 70 assert(alloc_first::allocator_constructed); 71 assert(alloc_last::allocator_constructed); 72 assert(std::get<0>(t) == 1); 73 assert(std::get<1>(t) == 2); 74 assert(std::get<2>(t) == 3); 75 } 76 } 77