//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11, c++14 #include #include #include #include #include "min_allocator.h" using namespace std; // [container.node.overview] Table 83. template struct node_compatibility_table { static constexpr bool value = is_same_v::node_type, typename map::node_type> && is_same_v::node_type, typename multimap::node_type> && is_same_v::node_type, typename set::node_type> && is_same_v::node_type, typename multiset::node_type> && is_same_v::node_type, typename unordered_map::node_type> && is_same_v::node_type, typename unordered_multimap::node_type> && is_same_v::node_type, typename unordered_set::node_type> && is_same_v::node_type, typename unordered_multiset::node_type>; }; template struct my_hash { using argument_type = T; using result_type = size_t; my_hash() = default; size_t operator()(const T&) const {return 0;} }; template struct my_compare { my_compare() = default; bool operator()(const T&, const T&) const {return true;} }; template struct my_equal { my_equal() = default; bool operator()(const T&, const T&) const {return true;} }; struct Static { Static() = default; Static(const Static&) = delete; Static(Static&&) = delete; Static& operator=(const Static&) = delete; Static& operator=(Static&&) = delete; }; namespace std { template <> struct hash { using argument_type = Static; using result_type = size_t; hash() = default; size_t operator()(const Static&) const; }; } static_assert(node_compatibility_table< int, int, std::less, std::less, std::hash, std::hash, std::equal_to, std::equal_to, std::allocator, std::allocator>>::value, ""); static_assert( node_compatibility_table, my_compare, std::hash, my_hash, std::equal_to, my_equal, allocator, allocator>>::value, ""); static_assert(node_compatibility_table< Static, int, my_compare, std::less, my_hash, std::hash, my_equal, std::equal_to, min_allocator, min_allocator>>::value, ""); template void test_node_handle_operations() { Container c; typename Container::node_type nt1, nt2 = c.extract(c.emplace().first); assert(nt2.get_allocator() == c.get_allocator()); assert(!nt2.empty()); assert(nt1.empty()); std::swap(nt1, nt2); assert(nt1.get_allocator() == c.get_allocator()); assert(nt2.empty()); } template void test_node_handle_operations_multi() { Container c; typename Container::node_type nt1, nt2 = c.extract(c.emplace()); assert(nt2.get_allocator() == c.get_allocator()); assert(!nt2.empty()); assert(nt1.empty()); std::swap(nt1, nt2); assert(nt1.get_allocator() == c.get_allocator()); assert(nt2.empty()); } template void test_typedef() {} template void test_insert_return_type() { test_typedef(); } int main() { test_node_handle_operations>(); test_node_handle_operations_multi>(); test_node_handle_operations>(); test_node_handle_operations_multi>(); test_node_handle_operations>(); test_node_handle_operations_multi>(); test_node_handle_operations>(); test_node_handle_operations_multi>(); test_insert_return_type>(); test_insert_return_type>(); test_insert_return_type>(); test_insert_return_type>(); }