1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8
9 // UNSUPPORTED: c++03
10
11 // Aligned allocation is required by std::experimental::pmr, but it was not provided
12 // before macosx10.13 and as a result we get linker errors when deploying to older than
13 // macosx10.13.
14 // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12}}
15
16 // <experimental/set>
17
18 // namespace std { namespace experimental { namespace pmr {
19 // template <class V, class Compare = less<V> >
20 // using set =
21 // ::std::set<V, Compare, polymorphic_allocator<V>>
22 //
23 // template <class V, class Compare = less<V> >
24 // using multiset =
25 // ::std::multiset<V, Compare, polymorphic_allocator<V>>
26 //
27 // }}} // namespace std::experimental::pmr
28
29 #include <experimental/set>
30 #include <experimental/memory_resource>
31 #include <type_traits>
32 #include <cassert>
33
34 #include "test_macros.h"
35
36 namespace pmr = std::experimental::pmr;
37
main(int,char **)38 int main(int, char**)
39 {
40 using V = char;
41 using DC = std::less<V>;
42 using OC = std::greater<V>;
43 {
44 using StdSet = std::set<V, DC, pmr::polymorphic_allocator<V>>;
45 using PmrSet = pmr::set<V>;
46 static_assert(std::is_same<StdSet, PmrSet>::value, "");
47 }
48 {
49 using StdSet = std::set<V, OC, pmr::polymorphic_allocator<V>>;
50 using PmrSet = pmr::set<V, OC>;
51 static_assert(std::is_same<StdSet, PmrSet>::value, "");
52 }
53 {
54 pmr::set<int> m;
55 assert(m.get_allocator().resource() == pmr::get_default_resource());
56 }
57 {
58 using StdSet = std::multiset<V, DC, pmr::polymorphic_allocator<V>>;
59 using PmrSet = pmr::multiset<V>;
60 static_assert(std::is_same<StdSet, PmrSet>::value, "");
61 }
62 {
63 using StdSet = std::multiset<V, OC, pmr::polymorphic_allocator<V>>;
64 using PmrSet = pmr::multiset<V, OC>;
65 static_assert(std::is_same<StdSet, PmrSet>::value, "");
66 }
67 {
68 pmr::multiset<int> m;
69 assert(m.get_allocator().resource() == pmr::get_default_resource());
70 }
71
72 return 0;
73 }
74