mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Utils: Added map key/value utility projections for std::ranges algorithms
This commit is contained in:
@@ -70,7 +70,7 @@ public:
|
||||
return { _storage.emplace(itr, std::move(newElement)), true };
|
||||
}
|
||||
|
||||
std::pair<iterator, bool> insert(Key const& key) { return emplace(key); }
|
||||
std::pair<iterator, bool> insert(Key const& key) { return this->emplace(key); }
|
||||
|
||||
std::size_t erase(Key const& key)
|
||||
{
|
||||
|
||||
@@ -65,5 +65,16 @@ void MultimapErasePair(M& multimap, typename M::key_type const& key, typename M:
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Map key projection for various std::ranges algorithms
|
||||
*/
|
||||
inline constexpr auto MapKey = []<typename Pair>(Pair&& pair) constexpr -> decltype(auto) { return (std::forward<Pair>(pair).first); /*Parentheses required for decltype(auto) to deduce a reference*/ };
|
||||
|
||||
/**
|
||||
* Map value projection for various std::ranges algorithms
|
||||
*/
|
||||
inline constexpr auto MapValue = []<typename Pair>(Pair&& pair) constexpr -> decltype(auto) { return (std::forward<Pair>(pair).second); /*Parentheses required for decltype(auto) to deduce a reference*/
|
||||
};
|
||||
}
|
||||
#endif // TRINITYCORE_MAP_UTILS_H
|
||||
|
||||
@@ -60,6 +60,9 @@ namespace Trinity
|
||||
{
|
||||
return Impl::new_from_tuple<T>(std::forward<Tuple>(args), std::make_index_sequence<std::tuple_size_v<std::remove_reference_t<Tuple>>>{});
|
||||
}
|
||||
|
||||
template <std::size_t I>
|
||||
inline constexpr auto TupleElement = []<typename Tuple>(Tuple&& tuple) constexpr -> decltype(auto) { return std::get<I>(std::forward<Tuple>(tuple)); };
|
||||
}
|
||||
|
||||
#endif // Tuples_h__
|
||||
|
||||
Reference in New Issue
Block a user