Make util::hash_table more heterogeneous-friendly
This commit is contained in:
parent
bd1393c505
commit
cbd99d1c4d
1 changed files with 14 additions and 19 deletions
|
|
@ -373,17 +373,14 @@ namespace psemek::util
|
||||||
: Hash(hash)
|
: Hash(hash)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
std::size_t operator()(Key const & key) const
|
template <typename Key1>
|
||||||
|
std::size_t operator()(Key1 const & key) const
|
||||||
{
|
{
|
||||||
return static_cast<Hash const &>(*this)(key);
|
return static_cast<Hash const &>(*this)(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t operator()(std::pair<Key const, Value> const & pair) const
|
template <typename Key1, typename Value1>
|
||||||
{
|
std::size_t operator()(std::pair<Key1, Value1> const & pair) const
|
||||||
return static_cast<Hash const &>(*this)(pair.first);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::size_t operator()(std::pair<Key, Value> const & pair) const
|
|
||||||
{
|
{
|
||||||
return static_cast<Hash const &>(*this)(pair.first);
|
return static_cast<Hash const &>(*this)(pair.first);
|
||||||
}
|
}
|
||||||
|
|
@ -397,22 +394,20 @@ namespace psemek::util
|
||||||
: Equal(equal)
|
: Equal(equal)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool operator()(Key const & key1, std::pair<Key const, Value> const & pair2) const
|
template <typename Key1, typename Key2, typename Value2>
|
||||||
|
bool operator()(Key1 const & key1, std::pair<Key2, Value2> const & pair2) const
|
||||||
{
|
{
|
||||||
return static_cast<Equal const &>(*this)(key1, pair2.first);
|
return static_cast<Equal const &>(*this)(key1, pair2.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator()(std::pair<Key const, Value> const & pair1, Key const & key2) const
|
template <typename Key1, typename Value1, typename Key2>
|
||||||
|
bool operator()(std::pair<Key1, Value1> const & pair1, Key2 const & key2) const
|
||||||
{
|
{
|
||||||
return static_cast<Equal const &>(*this)(pair1.first, key2);
|
return static_cast<Equal const &>(*this)(pair1.first, key2);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator()(std::pair<Key const, Value> const & pair1, std::pair<Key const, Value> const & pair2) const
|
template <typename Key1, typename Value1, typename Key2, typename Value2>
|
||||||
{
|
bool operator()(std::pair<Key1, Value1> const & pair1, std::pair<Key2, Value2> const & pair2) const
|
||||||
return static_cast<Equal const &>(*this)(pair1.first, pair2.first);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator()(std::pair<Key, Value> const & pair1, std::pair<Key const, Value> const & pair2) const
|
|
||||||
{
|
{
|
||||||
return static_cast<Equal const &>(*this)(pair1.first, pair2.first);
|
return static_cast<Equal const &>(*this)(pair1.first, pair2.first);
|
||||||
}
|
}
|
||||||
|
|
@ -644,7 +639,7 @@ namespace psemek::util
|
||||||
{
|
{
|
||||||
auto it = find(key);
|
auto it = find(key);
|
||||||
if (it == end())
|
if (it == end())
|
||||||
throw util::key_error{key};
|
throw util::key_error<Key>(key);
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -653,7 +648,7 @@ namespace psemek::util
|
||||||
{
|
{
|
||||||
auto it = find(key);
|
auto it = find(key);
|
||||||
if (it == end())
|
if (it == end())
|
||||||
throw util::key_error{key};
|
throw util::key_error<Key>(key);
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -661,7 +656,7 @@ namespace psemek::util
|
||||||
{
|
{
|
||||||
auto it = find(key);
|
auto it = find(key);
|
||||||
if (it == end())
|
if (it == end())
|
||||||
throw util::key_error{key};
|
throw util::key_error<Key>(key);
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -670,7 +665,7 @@ namespace psemek::util
|
||||||
{
|
{
|
||||||
auto it = find(key);
|
auto it = find(key);
|
||||||
if (it == end())
|
if (it == end())
|
||||||
throw util::key_error{key};
|
throw util::key_error<Key>(key);
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue