Eric Fiselier | dba23b4 | 2016-05-07 03:09:55 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===----------------------------------------------------------------------===// |
| 3 | // |
| 4 | // The LLVM Compiler Infrastructure |
| 5 | // |
| 6 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | // Source Licenses. See LICENSE.TXT for details. |
| 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | // UNSUPPORTED: c++98, c++03 |
| 12 | |
| 13 | // <experimental/map> |
| 14 | |
| 15 | // namespace std { namespace experimental { namespace pmr { |
| 16 | // template <class K, class V, class Compare = less<Key> > |
| 17 | // using map = |
| 18 | // ::std::map<K, V, Compare, polymorphic_allocator<pair<const K, V>>> |
| 19 | // |
| 20 | // template <class K, class V, class Compare = less<Key> > |
| 21 | // using multimap = |
| 22 | // ::std::multimap<K, V, Compare, polymorphic_allocator<pair<const K, V>>> |
| 23 | // |
| 24 | // }}} // namespace std::experimental::pmr |
| 25 | |
| 26 | #include <experimental/map> |
| 27 | #include <experimental/memory_resource> |
| 28 | #include <type_traits> |
| 29 | #include <cassert> |
| 30 | |
| 31 | namespace pmr = std::experimental::pmr; |
| 32 | |
| 33 | int main() |
| 34 | { |
| 35 | using K = int; |
| 36 | using V = char; |
| 37 | using DC = std::less<int>; |
| 38 | using OC = std::greater<int>; |
| 39 | using P = std::pair<const K, V>; |
| 40 | { |
| 41 | using StdMap = std::map<K, V, DC, pmr::polymorphic_allocator<P>>; |
| 42 | using PmrMap = pmr::map<K, V>; |
| 43 | static_assert(std::is_same<StdMap, PmrMap>::value, ""); |
| 44 | } |
| 45 | { |
| 46 | using StdMap = std::map<K, V, OC, pmr::polymorphic_allocator<P>>; |
| 47 | using PmrMap = pmr::map<K, V, OC>; |
| 48 | static_assert(std::is_same<StdMap, PmrMap>::value, ""); |
| 49 | } |
| 50 | { |
| 51 | pmr::map<int, int> m; |
| 52 | assert(m.get_allocator().resource() == pmr::get_default_resource()); |
| 53 | } |
| 54 | { |
| 55 | using StdMap = std::multimap<K, V, DC, pmr::polymorphic_allocator<P>>; |
| 56 | using PmrMap = pmr::multimap<K, V>; |
| 57 | static_assert(std::is_same<StdMap, PmrMap>::value, ""); |
| 58 | } |
| 59 | { |
| 60 | using StdMap = std::multimap<K, V, OC, pmr::polymorphic_allocator<P>>; |
| 61 | using PmrMap = pmr::multimap<K, V, OC>; |
| 62 | static_assert(std::is_same<StdMap, PmrMap>::value, ""); |
| 63 | } |
| 64 | { |
| 65 | pmr::multimap<int, int> m; |
| 66 | assert(m.get_allocator().resource() == pmr::get_default_resource()); |
| 67 | } |
| 68 | } |