From 5793c4bd9f5d3a8e9087d444beba202e753ec4c9 Mon Sep 17 00:00:00 2001 From: ras0219 <533828+ras0219@users.noreply.github.com> Date: Tue, 2 Feb 2021 15:00:33 -0800 Subject: [vcpkg] Miscellaneous internal improvements extracted from #15424 (#15677) * [vcpkg] Miscellaneous internal improvements extracted from #15424 * [vcpkg] CR comments * [armadillo] Use vcpkg_from_git() to workaround gitlab missing archive Co-authored-by: Robert Schumacher Co-authored-by: Billy Robert O'Neal III --- toolsrc/include/vcpkg-test/util.h | 6 ++++++ toolsrc/include/vcpkg/base/optional.h | 26 ++++++++++++++++++++------ toolsrc/include/vcpkg/dependencies.h | 2 +- toolsrc/include/vcpkg/remove.h | 1 - 4 files changed, 27 insertions(+), 8 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg-test/util.h b/toolsrc/include/vcpkg-test/util.h index d2c512f9b..1e20531fc 100644 --- a/toolsrc/include/vcpkg-test/util.h +++ b/toolsrc/include/vcpkg-test/util.h @@ -32,6 +32,12 @@ namespace Catch value.package_spec.triplet()); } }; + + template<> + struct StringMaker + { + static const std::string& convert(const vcpkg::Triplet& triplet) { return triplet.canonical_name(); } + }; } namespace vcpkg::Test diff --git a/toolsrc/include/vcpkg/base/optional.h b/toolsrc/include/vcpkg/base/optional.h index c66f891c7..d8c72ca6d 100644 --- a/toolsrc/include/vcpkg/base/optional.h +++ b/toolsrc/include/vcpkg/base/optional.h @@ -288,32 +288,46 @@ namespace vcpkg using map_t = decltype(std::declval()(std::declval())); template> - U then(F f) const& + Optional map(F f) const& { if (has_value()) { return f(this->m_base.value()); } - else + return nullopt; + } + + template> + U then(F f) const& + { + if (has_value()) { - return nullopt; + return f(this->m_base.value()); } + return nullopt; } template using move_map_t = decltype(std::declval()(std::declval())); template> - U then(F f) && + Optional map(F f) && { if (has_value()) { return f(std::move(this->m_base.value())); } - else + return nullopt; + } + + template> + U then(F f) && + { + if (has_value()) { - return nullopt; + return f(std::move(this->m_base.value())); } + return nullopt; } friend bool operator==(const Optional& lhs, const Optional& rhs) diff --git a/toolsrc/include/vcpkg/dependencies.h b/toolsrc/include/vcpkg/dependencies.h index 4736bc02c..1b1a7748b 100644 --- a/toolsrc/include/vcpkg/dependencies.h +++ b/toolsrc/include/vcpkg/dependencies.h @@ -132,7 +132,7 @@ namespace vcpkg::Dependencies RequestType request_type; Optional core_paragraph() const; - std::vector dependencies(Triplet triplet) const; + std::vector dependencies() const; private: Optional m_installed_package; diff --git a/toolsrc/include/vcpkg/remove.h b/toolsrc/include/vcpkg/remove.h index 06bdc23f5..faba3e368 100644 --- a/toolsrc/include/vcpkg/remove.h +++ b/toolsrc/include/vcpkg/remove.h @@ -23,7 +23,6 @@ namespace vcpkg::Remove extern const CommandStructure COMMAND_STRUCTURE; - void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, Triplet default_triplet); void remove_package(const VcpkgPaths& paths, const PackageSpec& spec, StatusParagraphs* status_db); struct RemoveCommand : Commands::TripletCommand -- cgit v1.2.3