65 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <tuple>10 11// template <class... Types> class tuple;12 13// template <class Alloc, class U1, class U2>14// tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);15 16// UNSUPPORTED: c++0317 18#include <tuple>19#include <utility>20#include <memory>21#include <cassert>22 23#include "test_macros.h"24#include "allocators.h"25#include "../alloc_first.h"26#include "../alloc_last.h"27 28struct B29{30 int id_;31 32 explicit B(int i) : id_(i) {}33 34 virtual ~B() {}35};36 37struct D38 : B39{40 explicit D(int i) : B(i) {}41};42 43int main(int, char**)44{45 {46 typedef std::pair<int, std::unique_ptr<D>> T0;47 typedef std::tuple<alloc_first, std::unique_ptr<B>> T1;48 T0 t0(2, std::unique_ptr<D>(new D(3)));49 alloc_first::allocator_constructed = false;50 T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));51 assert(alloc_first::allocator_constructed);52 assert(std::get<0>(t1) == 2);53 assert(std::get<1>(t1)->id_ == 3);54 }55 {56 // Test that we can use a tag derived from allocator_arg_t57 struct DerivedFromAllocatorArgT : std::allocator_arg_t { };58 DerivedFromAllocatorArgT derived;59 std::pair<int, int> from(1, 2);60 std::tuple<int, int> t0(derived, A1<int>(), std::move(from));61 }62 63 return 0;64}65