1 // Copyright (C) 2018-2019 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/>.
19 // { dg-options "-std=gnu++17 -pthread" }
20 // { dg-require-effective-target c++17 }
21 // { dg-require-effective-target pthread }
22 // { dg-require-gthreads "" }
24 #include <memory_resource>
25 #include <testsuite_hooks.h>
26 #include <testsuite_allocator.h>
31 __gnu_test::memory_resource test_mr1
, test_mr2
;
32 __gnu_test::default_resource_mgr
mgr(&test_mr1
);
34 const std::pmr::pool_options opts
{1, 2};
35 using std::pmr::synchronized_pool_resource
;
37 synchronized_pool_resource p1
= {opts
, &test_mr2
};
38 VERIFY( p1
.upstream_resource() == &test_mr2
);
39 synchronized_pool_resource p2
;
40 VERIFY( p2
.upstream_resource() == std::pmr::get_default_resource() );
41 synchronized_pool_resource p3
{&test_mr2
};
42 VERIFY( p3
.upstream_resource() == &test_mr2
);
43 synchronized_pool_resource p4
{opts
};
44 VERIFY( p4
.upstream_resource() == std::pmr::get_default_resource() );
46 static_assert(!std::is_copy_constructible_v
<synchronized_pool_resource
>);
47 static_assert(!std::is_copy_assignable_v
<synchronized_pool_resource
>);
48 static_assert(std::is_destructible_v
<synchronized_pool_resource
>);
54 __gnu_test::memory_resource test_mr1
, test_mr2
;
55 __gnu_test::default_resource_mgr
mgr(&test_mr1
);
57 const std::pmr::pool_options opts
{1, 2};
59 struct derived
: std::pmr::synchronized_pool_resource
61 using synchronized_pool_resource::synchronized_pool_resource
;
64 derived p1
= {opts
, &test_mr2
};
65 VERIFY( p1
.upstream_resource() == &test_mr2
);
67 VERIFY( p2
.upstream_resource() == std::pmr::get_default_resource() );
68 derived p3
{&test_mr2
};
69 VERIFY( p3
.upstream_resource() == &test_mr2
);
71 VERIFY( p4
.upstream_resource() == std::pmr::get_default_resource() );
73 static_assert(!std::is_copy_constructible_v
<derived
>);
74 static_assert(!std::is_copy_assignable_v
<derived
>);
75 static_assert(std::is_destructible_v
<derived
>);