From 6b10c8a4d33244338242abb9d36d6e38e35309c5 Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Tue, 14 Feb 2023 10:42:32 -0800 Subject: [PATCH] Update unordered_flat_map for new type traits --- .../boost/unordered/unordered_flat_map.hpp | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/include/boost/unordered/unordered_flat_map.hpp b/include/boost/unordered/unordered_flat_map.hpp index 16d4f3bd..7ceebc40 100644 --- a/include/boost/unordered/unordered_flat_map.hpp +++ b/include/boost/unordered/unordered_flat_map.hpp @@ -32,10 +32,8 @@ namespace boost { #pragma warning(disable : 4714) /* marked as __forceinline not inlined */ #endif - template - class unordered_flat_map - { - struct map_types + namespace detail { + template struct flat_map_types { using key_type = Key; using raw_key_type = typename std::remove_const::type; @@ -45,19 +43,46 @@ namespace boost { using moved_type = std::pair; using value_type = std::pair; + using element_type = value_type; + + static value_type& value_from(element_type& x) { return x; } + template static raw_key_type const& extract(std::pair const& kv) { return kv.first; } - static moved_type move(value_type& x) + static moved_type move(element_type& x) { // TODO: we probably need to launder here return {std::move(const_cast(x.first)), std::move(const_cast(x.second))}; } + + template + static void construct(A& al, element_type* p, moved_type&& x) + { + boost::allocator_construct(al, p, std::move(x)); + } + + template + static void construct(A& al, element_type* p, Args&&... args) + { + boost::allocator_construct(al, p, std::forward(args)...); + } + + template static void destroy(A& al, element_type* p) noexcept + { + boost::allocator_destroy(al, p); + } }; + } // namespace detail + + template + class unordered_flat_map + { + using map_types = detail::flat_map_types; using table_type = detail::foa::table