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/map>
13
14 // namespace std { namespace experimental { namespace pmr {
15 // template <class K, class V, class Compare = less<Key> >
16 // using map =
17 // ::std::map<K, V, Compare, polymorphic_allocator<pair<const K, V>>>
18 //
19 // template <class K, class V, class Compare = less<Key> >
20 // using multimap =
21 // ::std::multimap<K, V, Compare, polymorphic_allocator<pair<const K, V>>>
22 //
23 // }}} // namespace std::experimental::pmr
24
25 #include <experimental/map>
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 K = int;
37 using V = char;
38 using DC = std::less<int>;
39 using OC = std::greater<int>;
40 using P = std::pair<const K, V>;
41 {
42 using StdMap = std::map<K, V, DC, pmr::polymorphic_allocator<P>>;
43 using PmrMap = pmr::map<K, V>;
44 static_assert(std::is_same<StdMap, PmrMap>::value, "");
45 }
46 {
47 using StdMap = std::map<K, V, OC, pmr::polymorphic_allocator<P>>;
48 using PmrMap = pmr::map<K, V, OC>;
49 static_assert(std::is_same<StdMap, PmrMap>::value, "");
50 }
51 {
52 pmr::map<int, int> m;
53 assert(m.get_allocator().resource() == pmr::get_default_resource());
54 }
55 {
56 using StdMap = std::multimap<K, V, DC, pmr::polymorphic_allocator<P>>;
57 using PmrMap = pmr::multimap<K, V>;
58 static_assert(std::is_same<StdMap, PmrMap>::value, "");
59 }
60 {
61 using StdMap = std::multimap<K, V, OC, pmr::polymorphic_allocator<P>>;
62 using PmrMap = pmr::multimap<K, V, OC>;
63 static_assert(std::is_same<StdMap, PmrMap>::value, "");
64 }
65 {
66 pmr::multimap<int, int> m;
67 assert(m.get_allocator().resource() == pmr::get_default_resource());
68 }
69
70 return 0;
71 }
72