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 "MoveOnly.h" 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>(), std::move(t0)); 32 } 33 { 34 typedef std::tuple<MoveOnly> T; 35 T t0(MoveOnly(0)); 36 T t(std::allocator_arg, A1<int>(), std::move(t0)); 37 assert(std::get<0>(t) == 0); 38 } 39 { 40 typedef std::tuple<alloc_first> T; 41 T t0(1); 42 alloc_first::allocator_constructed = false; 43 T t(std::allocator_arg, A1<int>(5), std::move(t0)); 44 assert(alloc_first::allocator_constructed); 45 assert(std::get<0>(t) == 1); 46 } 47 { 48 typedef std::tuple<alloc_last> T; 49 T t0(1); 50 alloc_last::allocator_constructed = false; 51 T t(std::allocator_arg, A1<int>(5), std::move(t0)); 52 assert(alloc_last::allocator_constructed); 53 assert(std::get<0>(t) == 1); 54 } 55 // testing extensions 56 #ifdef _LIBCPP_VERSION 57 { 58 typedef std::tuple<MoveOnly, alloc_first> T; 59 T t0(0 ,1); 60 alloc_first::allocator_constructed = false; 61 T t(std::allocator_arg, A1<int>(5), std::move(t0)); 62 assert(alloc_first::allocator_constructed); 63 assert(std::get<0>(t) == 0); 64 assert(std::get<1>(t) == 1); 65 } 66 { 67 typedef std::tuple<MoveOnly, 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), std::move(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 #endif 79 } 80