diff options
author | Shauren <shauren.trinity@gmail.com> | 2025-02-23 11:33:53 +0100 |
---|---|---|
committer | Ovahlord <dreadkiller@gmx.de> | 2025-04-06 19:22:25 +0200 |
commit | 27e7a99106e7796057ca74cd4edfac28b09f6554 (patch) | |
tree | 0ad0438a4a8eee29a3fa1dea1181ec74eb77b6a9 /src/common/Containers/Utilities/MapUtils.h | |
parent | 7a2c949bf7618c8762949308ad1b6c1bc0edbee8 (diff) |
Core/Utils: Added map key/value utility projections for std::ranges algorithms
(cherry picked from commit 67418a1aeee9035234d304b5e9653b832488dd66)
Diffstat (limited to 'src/common/Containers/Utilities/MapUtils.h')
-rw-r--r-- | src/common/Containers/Utilities/MapUtils.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/common/Containers/Utilities/MapUtils.h b/src/common/Containers/Utilities/MapUtils.h index cb76a9d0579..e4cf6309bef 100644 --- a/src/common/Containers/Utilities/MapUtils.h +++ b/src/common/Containers/Utilities/MapUtils.h @@ -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 |