diff --git a/include/boost/unordered/detail/foa.hpp b/include/boost/unordered/detail/foa.hpp index 81698d09..abcf800a 100644 --- a/include/boost/unordered/detail/foa.hpp +++ b/include/boost/unordered/detail/foa.hpp @@ -828,12 +828,14 @@ table:empty_value,empty_value,empty_value public: using key_type=typename type_policy::key_type; - using init_type=typename type_policy::value_type; + using init_type=typename type_policy::init_type; using value_type=typename type_policy::value_type; private: static constexpr bool has_mutable_iterator= !std::is_same::value; + static constexpr bool has_different_init_type= + !std::is_same::value; public: using hasher=Hash; @@ -1207,6 +1209,17 @@ private: } } + template< + bool dependent_value=false, + typename std::enable_if< + has_different_init_type||dependent_value>::type* =nullptr + > + static inline auto key_from(const init_type& x) + ->decltype(type_policy::extract(x)) + { + return type_policy::extract(x); + } + static inline auto key_from(const value_type& x) ->decltype(type_policy::extract(x)) { diff --git a/include/boost/unordered/unordered_flat_map.hpp b/include/boost/unordered/unordered_flat_map.hpp index 864a33b8..c58ba91a 100644 --- a/include/boost/unordered/unordered_flat_map.hpp +++ b/include/boost/unordered/unordered_flat_map.hpp @@ -30,6 +30,7 @@ namespace boost { using key_type = Key; using init_type = std::pair; using value_type = std::pair; + static Key const& extract(init_type const& kv) { return kv.first; } static Key const& extract(value_type const& kv) { return kv.first; } template