From 74f788d04f2ff8ce66302b6be401ec9b7e85a42f Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Sat, 1 Apr 2017 01:09:34 -0700 Subject: [vcpkg] Replace explicit bulk operations with fmap --- toolsrc/include/vcpkg_Input.h | 9 ++++----- toolsrc/include/vcpkg_Util.h | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 toolsrc/include/vcpkg_Util.h (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg_Input.h b/toolsrc/include/vcpkg_Input.h index 96cbeecc3..4f102d029 100644 --- a/toolsrc/include/vcpkg_Input.h +++ b/toolsrc/include/vcpkg_Input.h @@ -5,11 +5,10 @@ namespace vcpkg::Input { - package_spec check_and_get_package_spec(const std::string& package_spec_as_string, const triplet& default_target_triplet, const std::string& example_text); - - std::vector check_and_get_package_specs(const std::vector& package_specs_as_strings, const triplet& default_target_triplet, const std::string& example_text); + package_spec check_and_get_package_spec( + const std::string& package_spec_as_string, + const triplet& default_target_triplet, + cstring_view example_text); void check_triplet(const triplet& t, const vcpkg_paths& paths); - - void check_triplets(const std::vector& triplets, const vcpkg_paths& paths); } diff --git a/toolsrc/include/vcpkg_Util.h b/toolsrc/include/vcpkg_Util.h new file mode 100644 index 000000000..4ebb2a802 --- /dev/null +++ b/toolsrc/include/vcpkg_Util.h @@ -0,0 +1,24 @@ +#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; + } +} \ No newline at end of file -- cgit v1.2.3