aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include
diff options
context:
space:
mode:
Diffstat (limited to 'toolsrc/include')
-rw-r--r--toolsrc/include/vcpkg_Util.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/toolsrc/include/vcpkg_Util.h b/toolsrc/include/vcpkg_Util.h
index bb93413ed..978407bd8 100644
--- a/toolsrc/include/vcpkg_Util.h
+++ b/toolsrc/include/vcpkg_Util.h
@@ -39,4 +39,14 @@ namespace vcpkg::Util
{
return std::find_if_not(cont.cbegin(), cont.cend(), pred);
}
+
+ template<class K, class V, class Container, class Func>
+ void group_by(const Container& cont, std::map<K, std::vector<const V*>>* output, Func f)
+ {
+ for (const V& element : cont)
+ {
+ K key = f(element);
+ (*output)[key].push_back(&element);
+ }
+ }
} \ No newline at end of file