1 // Copyright (C) 2018-2020 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-options "-std=gnu++17" }
19 // { dg-do run { target c++17 } }
21 #include <memory_resource>
22 #include <testsuite_hooks.h>
23 #include <testsuite_allocator.h>
28 __gnu_test::memory_resource test_mr1
, test_mr2
;
29 __gnu_test::default_resource_mgr
mgr(&test_mr1
);
31 const std::pmr::pool_options opts
{1, 2};
32 using std::pmr::unsynchronized_pool_resource
;
34 unsynchronized_pool_resource p1
= {opts
, &test_mr2
};
35 VERIFY( p1
.upstream_resource() == &test_mr2
);
36 unsynchronized_pool_resource p2
;
37 VERIFY( p2
.upstream_resource() == std::pmr::get_default_resource() );
38 unsynchronized_pool_resource p3
{&test_mr2
};
39 VERIFY( p3
.upstream_resource() == &test_mr2
);
40 unsynchronized_pool_resource p4
{opts
};
41 VERIFY( p4
.upstream_resource() == std::pmr::get_default_resource() );
43 static_assert(!std::is_copy_constructible_v
<unsynchronized_pool_resource
>);
44 static_assert(!std::is_copy_assignable_v
<unsynchronized_pool_resource
>);
45 static_assert(std::is_destructible_v
<unsynchronized_pool_resource
>);
51 __gnu_test::memory_resource test_mr1
, test_mr2
;
52 __gnu_test::default_resource_mgr
mgr(&test_mr1
);
54 const std::pmr::pool_options opts
{1, 2};
56 struct derived
: std::pmr::unsynchronized_pool_resource
58 using unsynchronized_pool_resource::unsynchronized_pool_resource
;
61 derived p1
= {opts
, &test_mr2
};
62 VERIFY( p1
.upstream_resource() == &test_mr2
);
64 VERIFY( p2
.upstream_resource() == std::pmr::get_default_resource() );
65 derived p3
{&test_mr2
};
66 VERIFY( p3
.upstream_resource() == &test_mr2
);
68 VERIFY( p4
.upstream_resource() == std::pmr::get_default_resource() );
70 static_assert(!std::is_copy_constructible_v
<derived
>);
71 static_assert(!std::is_copy_assignable_v
<derived
>);
72 static_assert(std::is_destructible_v
<derived
>);