alloc_move_pair.pass.cpp revision f5256e16dfc425c1d466f6308d4026d529ce9e0b
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. 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
26struct B
27{
28    int id_;
29
30    explicit B(int i) : id_(i) {}
31
32    virtual ~B() {}
33};
34
35struct D
36    : B
37{
38    explicit D(int i) : B(i) {}
39};
40
41
42int main()
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