1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9
10 // UNSUPPORTED: c++03
11
12 // <experimental/set>
13
14 // namespace std { namespace experimental { namespace pmr {
15 // template <class V, class Compare = less<V> >
16 // using set =
17 // ::std::set<V, Compare, polymorphic_allocator<V>>
18 //
19 // template <class V, class Compare = less<V> >
20 // using multiset =
21 // ::std::multiset<V, Compare, polymorphic_allocator<V>>
22 //
23 // }}} // namespace std::experimental::pmr
24
25 #include <experimental/set>
26 #include <experimental/memory_resource>
27 #include <type_traits>
28 #include <cassert>
29
30 #include "test_macros.h"
31
32 namespace pmr = std::experimental::pmr;
33
main(int,char **)34 int main(int, char**)
35 {
36 using V = char;
37 using DC = std::less<V>;
38 using OC = std::greater<V>;
39 {
40 using StdSet = std::set<V, DC, pmr::polymorphic_allocator<V>>;
41 using PmrSet = pmr::set<V>;
42 static_assert(std::is_same<StdSet, PmrSet>::value, "");
43 }
44 {
45 using StdSet = std::set<V, OC, pmr::polymorphic_allocator<V>>;
46 using PmrSet = pmr::set<V, OC>;
47 static_assert(std::is_same<StdSet, PmrSet>::value, "");
48 }
49 {
50 pmr::set<int> m;
51 assert(m.get_allocator().resource() == pmr::get_default_resource());
52 }
53 {
54 using StdSet = std::multiset<V, DC, pmr::polymorphic_allocator<V>>;
55 using PmrSet = pmr::multiset<V>;
56 static_assert(std::is_same<StdSet, PmrSet>::value, "");
57 }
58 {
59 using StdSet = std::multiset<V, OC, pmr::polymorphic_allocator<V>>;
60 using PmrSet = pmr::multiset<V, OC>;
61 static_assert(std::is_same<StdSet, PmrSet>::value, "");
62 }
63 {
64 pmr::multiset<int> m;
65 assert(m.get_allocator().resource() == pmr::get_default_resource());
66 }
67
68 return 0;
69 }
70