brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 6058835 Raw
68 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++1410// TODO: Change to XFAIL once https://llvm.org/PR40995 is fixed11// UNSUPPORTED: availability-pmr-missing12 13// <map>14 15// namespace std::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::pmr25 26#include <map>27#include <memory_resource>28#include <type_traits>29#include <cassert>30 31int main(int, char**) {32  using K  = int;33  using V  = char;34  using DC = std::less<int>;35  using OC = std::greater<int>;36  using P  = std::pair<const K, V>;37  {38    using StdMap = std::map<K, V, DC, std::pmr::polymorphic_allocator<P>>;39    using PmrMap = std::pmr::map<K, V>;40    static_assert(std::is_same<StdMap, PmrMap>::value, "");41  }42  {43    using StdMap = std::map<K, V, OC, std::pmr::polymorphic_allocator<P>>;44    using PmrMap = std::pmr::map<K, V, OC>;45    static_assert(std::is_same<StdMap, PmrMap>::value, "");46  }47  {48    std::pmr::map<int, int> m;49    assert(m.get_allocator().resource() == std::pmr::get_default_resource());50  }51  {52    using StdMap = std::multimap<K, V, DC, std::pmr::polymorphic_allocator<P>>;53    using PmrMap = std::pmr::multimap<K, V>;54    static_assert(std::is_same<StdMap, PmrMap>::value, "");55  }56  {57    using StdMap = std::multimap<K, V, OC, std::pmr::polymorphic_allocator<P>>;58    using PmrMap = std::pmr::multimap<K, V, OC>;59    static_assert(std::is_same<StdMap, PmrMap>::value, "");60  }61  {62    std::pmr::multimap<int, int> m;63    assert(m.get_allocator().resource() == std::pmr::get_default_resource());64  }65 66  return 0;67}68