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