xref: /llvm-project/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_map_synop.pass.cpp (revision 2da049a1418f7a2f96e7cac4368cac3ce8667d2e)
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 // <map>
14243da90eSArthur O'Dwyer 
15243da90eSArthur O'Dwyer // namespace std::pmr {
16243da90eSArthur O'Dwyer // template <class K, class V, class Compare = less<Key> >
17243da90eSArthur O'Dwyer // using map =
18243da90eSArthur O'Dwyer //     ::std::map<K, V, Compare, polymorphic_allocator<pair<const K, V>>>
19243da90eSArthur O'Dwyer //
20243da90eSArthur O'Dwyer // template <class K, class V, class Compare = less<Key> >
21243da90eSArthur O'Dwyer // using multimap =
22243da90eSArthur O'Dwyer //     ::std::multimap<K, V, Compare, polymorphic_allocator<pair<const K, V>>>
23243da90eSArthur O'Dwyer //
24243da90eSArthur O'Dwyer // } // namespace std::pmr
25243da90eSArthur O'Dwyer 
26243da90eSArthur O'Dwyer #include <map>
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 K  = int;
33243da90eSArthur O'Dwyer   using V  = char;
34243da90eSArthur O'Dwyer   using DC = std::less<int>;
35243da90eSArthur O'Dwyer   using OC = std::greater<int>;
36243da90eSArthur O'Dwyer   using P  = std::pair<const K, V>;
37243da90eSArthur O'Dwyer   {
38243da90eSArthur O'Dwyer     using StdMap = std::map<K, V, DC, std::pmr::polymorphic_allocator<P>>;
39243da90eSArthur O'Dwyer     using PmrMap = std::pmr::map<K, V>;
40243da90eSArthur O'Dwyer     static_assert(std::is_same<StdMap, PmrMap>::value, "");
41243da90eSArthur O'Dwyer   }
42243da90eSArthur O'Dwyer   {
43243da90eSArthur O'Dwyer     using StdMap = std::map<K, V, OC, std::pmr::polymorphic_allocator<P>>;
44243da90eSArthur O'Dwyer     using PmrMap = std::pmr::map<K, V, OC>;
45243da90eSArthur O'Dwyer     static_assert(std::is_same<StdMap, PmrMap>::value, "");
46243da90eSArthur O'Dwyer   }
47243da90eSArthur O'Dwyer   {
48243da90eSArthur O'Dwyer     std::pmr::map<int, int> m;
49243da90eSArthur O'Dwyer     assert(m.get_allocator().resource() == std::pmr::get_default_resource());
50243da90eSArthur O'Dwyer   }
51243da90eSArthur O'Dwyer   {
52243da90eSArthur O'Dwyer     using StdMap = std::multimap<K, V, DC, std::pmr::polymorphic_allocator<P>>;
53243da90eSArthur O'Dwyer     using PmrMap = std::pmr::multimap<K, V>;
54243da90eSArthur O'Dwyer     static_assert(std::is_same<StdMap, PmrMap>::value, "");
55243da90eSArthur O'Dwyer   }
56243da90eSArthur O'Dwyer   {
57243da90eSArthur O'Dwyer     using StdMap = std::multimap<K, V, OC, std::pmr::polymorphic_allocator<P>>;
58243da90eSArthur O'Dwyer     using PmrMap = std::pmr::multimap<K, V, OC>;
59243da90eSArthur O'Dwyer     static_assert(std::is_same<StdMap, PmrMap>::value, "");
60243da90eSArthur O'Dwyer   }
61243da90eSArthur O'Dwyer   {
62243da90eSArthur O'Dwyer     std::pmr::multimap<int, int> m;
63243da90eSArthur O'Dwyer     assert(m.get_allocator().resource() == std::pmr::get_default_resource());
64243da90eSArthur O'Dwyer   }
65243da90eSArthur O'Dwyer 
66243da90eSArthur O'Dwyer   return 0;
67243da90eSArthur O'Dwyer }
68