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 //===----------------------------------------------------------------------===//
11 // XFAIL: availability-aligned_allocation-missing
15 // namespace std { namespace experimental { namespace pmr {
16 // template <class K, class V, class Compare = less<Key> >
18 // ::std::map<K, V, Compare, polymorphic_allocator<pair<const K, V>>>
20 // template <class K, class V, class Compare = less<Key> >
22 // ::std::multimap<K, V, Compare, polymorphic_allocator<pair<const K, V>>>
24 // }}} // namespace std::experimental::pmr
26 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
28 #include <experimental/map>
29 #include <experimental/memory_resource>
30 #include <type_traits>
33 #include "test_macros.h"
35 namespace pmr
= std::experimental::pmr
;
41 using DC
= std::less
<int>;
42 using OC
= std::greater
<int>;
43 using P
= std::pair
<const K
, V
>;
45 using StdMap
= std::map
<K
, V
, DC
, pmr::polymorphic_allocator
<P
>>;
46 using PmrMap
= pmr::map
<K
, V
>;
47 static_assert(std::is_same
<StdMap
, PmrMap
>::value
, "");
50 using StdMap
= std::map
<K
, V
, OC
, pmr::polymorphic_allocator
<P
>>;
51 using PmrMap
= pmr::map
<K
, V
, OC
>;
52 static_assert(std::is_same
<StdMap
, PmrMap
>::value
, "");
56 assert(m
.get_allocator().resource() == pmr::get_default_resource());
59 using StdMap
= std::multimap
<K
, V
, DC
, pmr::polymorphic_allocator
<P
>>;
60 using PmrMap
= pmr::multimap
<K
, V
>;
61 static_assert(std::is_same
<StdMap
, PmrMap
>::value
, "");
64 using StdMap
= std::multimap
<K
, V
, OC
, pmr::polymorphic_allocator
<P
>>;
65 using PmrMap
= pmr::multimap
<K
, V
, OC
>;
66 static_assert(std::is_same
<StdMap
, PmrMap
>::value
, "");
69 pmr::multimap
<int, int> m
;
70 assert(m
.get_allocator().resource() == pmr::get_default_resource());