mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-06-07 01:52:48 +08:00
Introduce Maps::transform_values()
This commit is contained in:
parent
aa57df6d6e
commit
69dfad795f
@ -3,6 +3,7 @@
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -29,6 +30,17 @@ namespace vcpkg::Util
|
||||
}
|
||||
}
|
||||
|
||||
namespace Maps
|
||||
{
|
||||
template<class K, class V1, class V2, class Func>
|
||||
void transform_values(const std::unordered_map<K, V1>& container, std::unordered_map<K, V2>& output, Func func)
|
||||
{
|
||||
std::for_each(container.cbegin(), container.cend(), [&](const std::pair<const K, V1>& p) {
|
||||
output[p.first] = func(p.second);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
template<class Cont, class Func>
|
||||
using FmapOut = decltype(std::declval<Func&>()(*begin(std::declval<Cont&>())));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user