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