1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14
10 // TODO: Change to XFAIL once https://github.com/llvm/llvm-project/issues/40340 is fixed
11 // UNSUPPORTED: availability-pmr-missing
15 // namespace std::pmr {
16 // template <class V, class Compare = less<V> >
18 // ::std::set<V, Compare, polymorphic_allocator<V>>
20 // template <class V, class Compare = less<V> >
22 // ::std::multiset<V, Compare, polymorphic_allocator<V>>
24 // } // namespace std::pmr
27 #include <memory_resource>
28 #include <type_traits>
31 int main(int, char**) {
33 using DC
= std::less
<V
>;
34 using OC
= std::greater
<V
>;
36 using StdSet
= std::set
<V
, DC
, std::pmr::polymorphic_allocator
<V
>>;
37 using PmrSet
= std::pmr::set
<V
>;
38 static_assert(std::is_same
<StdSet
, PmrSet
>::value
, "");
41 using StdSet
= std::set
<V
, OC
, std::pmr::polymorphic_allocator
<V
>>;
42 using PmrSet
= std::pmr::set
<V
, OC
>;
43 static_assert(std::is_same
<StdSet
, PmrSet
>::value
, "");
47 assert(m
.get_allocator().resource() == std::pmr::get_default_resource());
50 using StdSet
= std::multiset
<V
, DC
, std::pmr::polymorphic_allocator
<V
>>;
51 using PmrSet
= std::pmr::multiset
<V
>;
52 static_assert(std::is_same
<StdSet
, PmrSet
>::value
, "");
55 using StdSet
= std::multiset
<V
, OC
, std::pmr::polymorphic_allocator
<V
>>;
56 using PmrSet
= std::pmr::multiset
<V
, OC
>;
57 static_assert(std::is_same
<StdSet
, PmrSet
>::value
, "");
60 std::pmr::multiset
<int> m
;
61 assert(m
.get_allocator().resource() == std::pmr::get_default_resource());