]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/polymorphic_allocator/select.cc
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/>.
18 // { dg-options "-std=gnu++17" }
19 // { dg-do run { target c++17 } }
20 // { dg-skip-if "" { *-*-* } { -fno-aligned-new } }
22 #include <memory_resource>
23 #include <testsuite_allocator.h>
25 struct X
{ int i
= 0; };
27 using test_type
= std::pmr::polymorphic_allocator
<X
>;
33 VERIFY( a
.select_on_container_copy_construction() == a
);
34 VERIFY( a
.select_on_container_copy_construction() == b
);
36 __gnu_test::memory_resource r
;
38 VERIFY( c
.select_on_container_copy_construction() != c
);
39 VERIFY( c
.select_on_container_copy_construction() == a
);
45 __gnu_test::memory_resource r
;
47 VERIFY( a
.select_on_container_copy_construction() != a
);
48 std::pmr::set_default_resource(&r
);
49 VERIFY( a
.select_on_container_copy_construction() == a
);
50 std::pmr::set_default_resource(nullptr);