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, class U1, class U2>
14 //   tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
15 
16 // UNSUPPORTED: c++98, c++03
17 
18 #include <tuple>
19 #include <utility>
20 #include <memory>
21 #include <cassert>
22 
23 #include "allocators.h"
24 #include "../alloc_first.h"
25 #include "../alloc_last.h"
26 
27 struct B
28 {
29     int id_;
30 
31     explicit B(int i) : id_(i) {}
32 
33     virtual ~B() {}
34 };
35 
36 struct D
37     : B
38 {
39     explicit D(int i) : B(i) {}
40 };
41 
42 int main(int, char**)
43 {
44     {
45         typedef std::pair<int, std::unique_ptr<D>> T0;
46         typedef std::tuple<alloc_first, std::unique_ptr<B>> T1;
47         T0 t0(2, std::unique_ptr<D>(new D(3)));
48         alloc_first::allocator_constructed = false;
49         T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
50         assert(alloc_first::allocator_constructed);
51         assert(std::get<0>(t1) == 2);
52         assert(std::get<1>(t1)->id_ == 3);
53     }
54 
55   return 0;
56 }
57