summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/copy.pass.cpp
blob: ba3710d4de1ba6b8aac9fa02f89ec33dffed154d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++98, c++03

// <experimental/memory_resource>

// template <class T> class polymorphic_allocator

// polymorphic_allocator<T>::polymorphic_allocator(polymorphic_allocator const &);

#include <experimental/memory_resource>
#include <type_traits>
#include <cassert>

namespace ex = std::experimental::pmr;

int main()
{
    typedef ex::polymorphic_allocator<void> A1;
    {
        static_assert(
            std::is_copy_constructible<A1>::value, ""
          );
        static_assert(
            std::is_move_constructible<A1>::value, ""
          );
    }
    // copy
    {
        A1 const a((ex::memory_resource*)42);
        A1 const a2(a);
        assert(a.resource() == a2.resource());
    }
    // move
    {
        A1 a((ex::memory_resource*)42);
        A1 a2(std::move(a));
        assert(a.resource() == a2.resource());
        assert(a2.resource() == (ex::memory_resource*)42);
    }
}
OpenPOWER on IntegriCloud