brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 60ad57e Raw
66 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// <set>14 15// namespace std::pmr {16// template <class V, class Compare = less<V> >17// using set =18//     ::std::set<V, Compare, polymorphic_allocator<V>>19//20// template <class V, class Compare = less<V> >21// using multiset =22//     ::std::multiset<V, Compare, polymorphic_allocator<V>>23//24// } // namespace std::pmr25 26#include <set>27#include <memory_resource>28#include <type_traits>29#include <cassert>30 31int main(int, char**) {32  using V  = char;33  using DC = std::less<V>;34  using OC = std::greater<V>;35  {36    using StdSet = std::set<V, DC, std::pmr::polymorphic_allocator<V>>;37    using PmrSet = std::pmr::set<V>;38    static_assert(std::is_same<StdSet, PmrSet>::value, "");39  }40  {41    using StdSet = std::set<V, OC, std::pmr::polymorphic_allocator<V>>;42    using PmrSet = std::pmr::set<V, OC>;43    static_assert(std::is_same<StdSet, PmrSet>::value, "");44  }45  {46    std::pmr::set<int> m;47    assert(m.get_allocator().resource() == std::pmr::get_default_resource());48  }49  {50    using StdSet = std::multiset<V, DC, std::pmr::polymorphic_allocator<V>>;51    using PmrSet = std::pmr::multiset<V>;52    static_assert(std::is_same<StdSet, PmrSet>::value, "");53  }54  {55    using StdSet = std::multiset<V, OC, std::pmr::polymorphic_allocator<V>>;56    using PmrSet = std::pmr::multiset<V, OC>;57    static_assert(std::is_same<StdSet, PmrSet>::value, "");58  }59  {60    std::pmr::multiset<int> m;61    assert(m.get_allocator().resource() == std::pmr::get_default_resource());62  }63 64  return 0;65}66