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/set> |
| 14 | |
| 15 | // namespace std { namespace experimental { namespace 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::experimental::pmr |
| 25 | |
| 26 | #include <experimental/set> |
| 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 V = char; |
| 36 | using DC = std::less<V>; |
| 37 | using OC = std::greater<V>; |
| 38 | { |
| 39 | using StdSet = std::set<V, DC, pmr::polymorphic_allocator<V>>; |
| 40 | using PmrSet = pmr::set<V>; |
| 41 | static_assert(std::is_same<StdSet, PmrSet>::value, ""); |
| 42 | } |
| 43 | { |
| 44 | using StdSet = std::set<V, OC, pmr::polymorphic_allocator<V>>; |
| 45 | using PmrSet = pmr::set<V, OC>; |
| 46 | static_assert(std::is_same<StdSet, PmrSet>::value, ""); |
| 47 | } |
| 48 | { |
| 49 | pmr::set<int> m; |
| 50 | assert(m.get_allocator().resource() == pmr::get_default_resource()); |
| 51 | } |
| 52 | { |
| 53 | using StdSet = std::multiset<V, DC, pmr::polymorphic_allocator<V>>; |
| 54 | using PmrSet = pmr::multiset<V>; |
| 55 | static_assert(std::is_same<StdSet, PmrSet>::value, ""); |
| 56 | } |
| 57 | { |
| 58 | using StdSet = std::multiset<V, OC, pmr::polymorphic_allocator<V>>; |
| 59 | using PmrSet = pmr::multiset<V, OC>; |
| 60 | static_assert(std::is_same<StdSet, PmrSet>::value, ""); |
| 61 | } |
| 62 | { |
| 63 | pmr::multiset<int> m; |
| 64 | assert(m.get_allocator().resource() == pmr::get_default_resource()); |
| 65 | } |
| 66 | } |