libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

header_set_synop.pass.cpp (2053B)


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