1243da90eSArthur O'Dwyer //===----------------------------------------------------------------------===//
2243da90eSArthur O'Dwyer //
3243da90eSArthur O'Dwyer // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4243da90eSArthur O'Dwyer // See https://llvm.org/LICENSE.txt for license information.
5243da90eSArthur O'Dwyer // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6243da90eSArthur O'Dwyer //
7243da90eSArthur O'Dwyer //===----------------------------------------------------------------------===//
8243da90eSArthur O'Dwyer
9243da90eSArthur O'Dwyer // UNSUPPORTED: c++03, c++11, c++14
10*2da049a1SLouis Dionne // TODO: Change to XFAIL once https://github.com/llvm/llvm-project/issues/40340 is fixed
11*2da049a1SLouis Dionne // UNSUPPORTED: availability-pmr-missing
12243da90eSArthur O'Dwyer
13243da90eSArthur O'Dwyer // <set>
14243da90eSArthur O'Dwyer
15243da90eSArthur O'Dwyer // namespace std::pmr {
16243da90eSArthur O'Dwyer // template <class V, class Compare = less<V> >
17243da90eSArthur O'Dwyer // using set =
18243da90eSArthur O'Dwyer // ::std::set<V, Compare, polymorphic_allocator<V>>
19243da90eSArthur O'Dwyer //
20243da90eSArthur O'Dwyer // template <class V, class Compare = less<V> >
21243da90eSArthur O'Dwyer // using multiset =
22243da90eSArthur O'Dwyer // ::std::multiset<V, Compare, polymorphic_allocator<V>>
23243da90eSArthur O'Dwyer //
24243da90eSArthur O'Dwyer // } // namespace std::pmr
25243da90eSArthur O'Dwyer
26243da90eSArthur O'Dwyer #include <set>
27243da90eSArthur O'Dwyer #include <memory_resource>
28243da90eSArthur O'Dwyer #include <type_traits>
29243da90eSArthur O'Dwyer #include <cassert>
30243da90eSArthur O'Dwyer
main(int,char **)31243da90eSArthur O'Dwyer int main(int, char**) {
32243da90eSArthur O'Dwyer using V = char;
33243da90eSArthur O'Dwyer using DC = std::less<V>;
34243da90eSArthur O'Dwyer using OC = std::greater<V>;
35243da90eSArthur O'Dwyer {
36243da90eSArthur O'Dwyer using StdSet = std::set<V, DC, std::pmr::polymorphic_allocator<V>>;
37243da90eSArthur O'Dwyer using PmrSet = std::pmr::set<V>;
38243da90eSArthur O'Dwyer static_assert(std::is_same<StdSet, PmrSet>::value, "");
39243da90eSArthur O'Dwyer }
40243da90eSArthur O'Dwyer {
41243da90eSArthur O'Dwyer using StdSet = std::set<V, OC, std::pmr::polymorphic_allocator<V>>;
42243da90eSArthur O'Dwyer using PmrSet = std::pmr::set<V, OC>;
43243da90eSArthur O'Dwyer static_assert(std::is_same<StdSet, PmrSet>::value, "");
44243da90eSArthur O'Dwyer }
45243da90eSArthur O'Dwyer {
46243da90eSArthur O'Dwyer std::pmr::set<int> m;
47243da90eSArthur O'Dwyer assert(m.get_allocator().resource() == std::pmr::get_default_resource());
48243da90eSArthur O'Dwyer }
49243da90eSArthur O'Dwyer {
50243da90eSArthur O'Dwyer using StdSet = std::multiset<V, DC, std::pmr::polymorphic_allocator<V>>;
51243da90eSArthur O'Dwyer using PmrSet = std::pmr::multiset<V>;
52243da90eSArthur O'Dwyer static_assert(std::is_same<StdSet, PmrSet>::value, "");
53243da90eSArthur O'Dwyer }
54243da90eSArthur O'Dwyer {
55243da90eSArthur O'Dwyer using StdSet = std::multiset<V, OC, std::pmr::polymorphic_allocator<V>>;
56243da90eSArthur O'Dwyer using PmrSet = std::pmr::multiset<V, OC>;
57243da90eSArthur O'Dwyer static_assert(std::is_same<StdSet, PmrSet>::value, "");
58243da90eSArthur O'Dwyer }
59243da90eSArthur O'Dwyer {
60243da90eSArthur O'Dwyer std::pmr::multiset<int> m;
61243da90eSArthur O'Dwyer assert(m.get_allocator().resource() == std::pmr::get_default_resource());
62243da90eSArthur O'Dwyer }
63243da90eSArthur O'Dwyer
64243da90eSArthur O'Dwyer return 0;
65243da90eSArthur O'Dwyer }
66