1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // <tuple> 10 11 // template <class... Types> class tuple; 12 13 // template <class Alloc> 14 // tuple(allocator_arg_t, const Alloc& a, tuple&&); 15 16 // UNSUPPORTED: c++98, c++03 17 18 #include <tuple> 19 #include <cassert> 20 21 #include "test_macros.h" 22 #include "MoveOnly.h" 23 #include "allocators.h" 24 #include "../alloc_first.h" 25 #include "../alloc_last.h" 26 27 int main(int, char**) 28 { 29 { 30 typedef std::tuple<> T; 31 T t0; 32 T t(std::allocator_arg, A1<int>(), std::move(t0)); 33 } 34 { 35 typedef std::tuple<MoveOnly> T; 36 T t0(MoveOnly(0)); 37 T t(std::allocator_arg, A1<int>(), std::move(t0)); 38 assert(std::get<0>(t) == 0); 39 } 40 { 41 typedef std::tuple<alloc_first> T; 42 T t0(1); 43 alloc_first::allocator_constructed = false; 44 T t(std::allocator_arg, A1<int>(5), std::move(t0)); 45 assert(alloc_first::allocator_constructed); 46 assert(std::get<0>(t) == 1); 47 } 48 { 49 typedef std::tuple<alloc_last> T; 50 T t0(1); 51 alloc_last::allocator_constructed = false; 52 T t(std::allocator_arg, A1<int>(5), std::move(t0)); 53 assert(alloc_last::allocator_constructed); 54 assert(std::get<0>(t) == 1); 55 } 56 // testing extensions 57 #ifdef _LIBCPP_VERSION 58 { 59 typedef std::tuple<MoveOnly, alloc_first> T; 60 T t0(0 ,1); 61 alloc_first::allocator_constructed = false; 62 T t(std::allocator_arg, A1<int>(5), std::move(t0)); 63 assert(alloc_first::allocator_constructed); 64 assert(std::get<0>(t) == 0); 65 assert(std::get<1>(t) == 1); 66 } 67 { 68 typedef std::tuple<MoveOnly, alloc_first, alloc_last> T; 69 T t0(1, 2, 3); 70 alloc_first::allocator_constructed = false; 71 alloc_last::allocator_constructed = false; 72 T t(std::allocator_arg, A1<int>(5), std::move(t0)); 73 assert(alloc_first::allocator_constructed); 74 assert(alloc_last::allocator_constructed); 75 assert(std::get<0>(t) == 1); 76 assert(std::get<1>(t) == 2); 77 assert(std::get<2>(t) == 3); 78 } 79 #endif 80 81 return 0; 82 } 83