fixed init_type machinery

This commit is contained in:
joaquintides
2022-10-05 18:46:38 +02:00
parent c15bd0092d
commit 7c8045aab5
2 changed files with 15 additions and 1 deletions

View File

@ -828,12 +828,14 @@ table:empty_value<Hash,0>,empty_value<Pred,1>,empty_value<Allocator,1>
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<key_type,value_type>::value;
static constexpr bool has_different_init_type=
!std::is_same<init_type,value_type>::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))
{

View File

@ -30,6 +30,7 @@ namespace boost {
using key_type = Key;
using init_type = std::pair<Key, T>;
using value_type = std::pair<Key const, T>;
static Key const& extract(init_type const& kv) { return kv.first; }
static Key const& extract(value_type const& kv) { return kv.first; }
template<typename F>