1 // Copyright (C) 2018-2022 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-do run { target c++17 } }
20 #include <memory_resource>
21 #include <testsuite_hooks.h>
22 #include <testsuite_allocator.h>
27 __gnu_test::memory_resource test_mr1
, test_mr2
;
28 __gnu_test::default_resource_mgr
mgr(&test_mr1
);
30 const std::pmr::pool_options opts
{1, 2};
31 using std::pmr::unsynchronized_pool_resource
;
33 unsynchronized_pool_resource p1
= {opts
, &test_mr2
};
34 VERIFY( p1
.upstream_resource() == &test_mr2
);
35 unsynchronized_pool_resource p2
;
36 VERIFY( p2
.upstream_resource() == std::pmr::get_default_resource() );
37 unsynchronized_pool_resource p3
{&test_mr2
};
38 VERIFY( p3
.upstream_resource() == &test_mr2
);
39 unsynchronized_pool_resource p4
{opts
};
40 VERIFY( p4
.upstream_resource() == std::pmr::get_default_resource() );
42 static_assert(!std::is_copy_constructible_v
<unsynchronized_pool_resource
>);
43 static_assert(!std::is_copy_assignable_v
<unsynchronized_pool_resource
>);
44 static_assert(std::is_destructible_v
<unsynchronized_pool_resource
>);
50 __gnu_test::memory_resource test_mr1
, test_mr2
;
51 __gnu_test::default_resource_mgr
mgr(&test_mr1
);
53 const std::pmr::pool_options opts
{1, 2};
55 struct derived
: std::pmr::unsynchronized_pool_resource
57 using unsynchronized_pool_resource::unsynchronized_pool_resource
;
60 derived p1
= {opts
, &test_mr2
};
61 VERIFY( p1
.upstream_resource() == &test_mr2
);
63 VERIFY( p2
.upstream_resource() == std::pmr::get_default_resource() );
64 derived p3
{&test_mr2
};
65 VERIFY( p3
.upstream_resource() == &test_mr2
);
67 VERIFY( p4
.upstream_resource() == std::pmr::get_default_resource() );
69 static_assert(!std::is_copy_constructible_v
<derived
>);
70 static_assert(!std::is_copy_assignable_v
<derived
>);
71 static_assert(std::is_destructible_v
<derived
>);