#pragma once #include #include namespace vcpkg::Util { template using FmapOut = decltype(std::declval()(std::declval()[0])); template> std::vector fmap(const Cont& xs, Func&& f) { using O = decltype(f(xs[0])); std::vector ret; ret.reserve(xs.size()); for (auto&& x : xs) ret.push_back(f(x)); return ret; } template void unstable_keep_if(Container& cont, Pred pred) { cont.erase(std::partition(cont.begin(), cont.end(), pred), cont.end()); } template void erase_remove_if(Container& cont, Pred pred) { cont.erase(std::remove_if(cont.begin(), cont.end(), pred), cont.end()); } template auto find(const Container& cont, V&& v) { return std::find(cont.cbegin(), cont.cend(), v); } template auto find_if(const Container& cont, Pred pred) { return std::find_if(cont.cbegin(), cont.cend(), pred); } template auto find_if_not(const Container& cont, Pred pred) { return std::find_if_not(cont.cbegin(), cont.cend(), pred); } template void group_by(const Container& cont, std::map>* output, Func f) { for (const V& element : cont) { K key = f(element); (*output)[key].push_back(&element); } } }