From 8d79a526999274afa8a7bad8f263dd129881ee58 Mon Sep 17 00:00:00 2001 From: Rose <83477269+AtariDreams@users.noreply.github.com> Date: Fri, 21 Oct 2022 13:07:45 -0400 Subject: [PATCH] Mark functions as static and const Also use constexpr where we can --- include/vcpkg/base/format.h | 4 ++-- include/vcpkg/base/messages.h | 2 +- include/vcpkg/binarycaching.h | 2 +- include/vcpkg/build.h | 2 +- include/vcpkg/configuration.h | 2 +- include/vcpkg/export.prefab.h | 18 +++++++++--------- include/vcpkg/metrics.h | 20 ++++++++++---------- include/vcpkg/paragraphparser.h | 2 +- include/vcpkg/xunitwriter.h | 2 +- src/vcpkg-fuzz/main.cpp | 4 ++-- src/vcpkg-test/dependencies.cpp | 2 +- src/vcpkg-test/expected.cpp | 5 +++-- src/vcpkg-test/hash.cpp | 8 ++++---- src/vcpkg-test/optional.cpp | 4 ++-- src/vcpkg/base/downloads.cpp | 2 +- src/vcpkg/base/json.cpp | 4 ++-- src/vcpkg/base/strings.cpp | 2 +- src/vcpkg/base/system.process.cpp | 2 +- src/vcpkg/binarycaching.cpp | 2 +- src/vcpkg/build.cpp | 10 +++++----- src/vcpkg/commands.version.cpp | 2 +- src/vcpkg/configuration.cpp | 2 +- src/vcpkg/dependencies.cpp | 11 ++++++----- src/vcpkg/export.prefab.cpp | 12 ++++++------ src/vcpkg/install.cpp | 4 ++-- src/vcpkg/paragraphs.cpp | 2 +- src/vcpkg/registries.cpp | 2 +- src/vcpkg/sourceparagraph.cpp | 2 +- src/vcpkg/xunitwriter.cpp | 2 +- 29 files changed, 70 insertions(+), 68 deletions(-) diff --git a/include/vcpkg/base/format.h b/include/vcpkg/base/format.h index 7017f2261c..2b9774bdd2 100644 --- a/include/vcpkg/base/format.h +++ b/include/vcpkg/base/format.h @@ -25,7 +25,7 @@ namespace fmt template<> struct formatter { - constexpr auto parse(format_parse_context& ctx) const -> decltype(ctx.begin()) + static constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { return vcpkg::basic_format_parse_impl(ctx); } @@ -49,7 +49,7 @@ namespace fmt template<> struct formatter : formatter { - constexpr auto parse(format_parse_context& ctx) const -> decltype(ctx.begin()) + static constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { return vcpkg::basic_format_parse_impl(ctx); } diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 2221577b7e..2042897182 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -106,7 +106,7 @@ namespace vcpkg return lhs.data() >= rhs.data(); } - bool empty() { return m_data.empty(); } + bool empty() const { return m_data.empty(); } void clear() { m_data.clear(); } private: diff --git a/include/vcpkg/binarycaching.h b/include/vcpkg/binarycaching.h index 9d2e618b1f..378a8001b4 100644 --- a/include/vcpkg/binarycaching.h +++ b/include/vcpkg/binarycaching.h @@ -76,7 +76,7 @@ namespace vcpkg std::vector headers_for_put; std::vector headers_for_get; - LocalizedString valid(); + LocalizedString valid() const; std::string instantiate_variables(const InstallPlanAction& action) const; }; diff --git a/include/vcpkg/build.h b/include/vcpkg/build.h index 9d02c12cef..feefb1dacc 100644 --- a/include/vcpkg/build.h +++ b/include/vcpkg/build.h @@ -415,7 +415,7 @@ namespace vcpkg Cache m_triplet_cache; Cache m_toolchain_cache; - const TripletMapEntry& get_triplet_cache(const Filesystem& fs, const Path& p); + const TripletMapEntry& get_triplet_cache(const Filesystem& fs, const Path& p) const; #if defined(_WIN32) struct EnvMapEntry diff --git a/include/vcpkg/configuration.h b/include/vcpkg/configuration.h index 5aa0831640..23232cb6d5 100644 --- a/include/vcpkg/configuration.h +++ b/include/vcpkg/configuration.h @@ -38,7 +38,7 @@ namespace vcpkg std::vector overlay_triplets; Json::Object serialize() const; - void validate_as_active(); + void validate_as_active() const; std::unique_ptr instantiate_registry_set(const VcpkgPaths& paths, const Path& config_dir) const; diff --git a/include/vcpkg/export.prefab.h b/include/vcpkg/export.prefab.h index 8940843b66..7bcf72e4d8 100644 --- a/include/vcpkg/export.prefab.h +++ b/include/vcpkg/export.prefab.h @@ -25,11 +25,11 @@ namespace vcpkg::Export::Prefab struct NdkVersion { NdkVersion(int _major, int _minor, int _patch) : m_major{_major}, m_minor{_minor}, m_patch{_patch} { } - int major() { return this->m_major; } - int minor() { return this->m_minor; } - int patch() { return this->m_patch; } - std::string to_string(); - void to_string(std::string& out); + int major() const { return this->m_major; } + int minor() const { return this->m_minor; } + int patch() const { return this->m_patch; } + std::string to_string() const; + void to_string(std::string& out) const; friend bool operator==(const NdkVersion& lhs, const NdkVersion& rhs) { @@ -49,14 +49,14 @@ namespace vcpkg::Export::Prefab int api; int ndk; std::string stl; - std::string to_string(); + std::string to_string() const; }; struct PlatformModuleMetadata { std::vector export_libraries; std::string library_name; - std::string to_json(); + std::string to_json() const; }; struct ModuleMetadata @@ -64,7 +64,7 @@ namespace vcpkg::Export::Prefab std::vector export_libraries; std::string library_name; PlatformModuleMetadata android; - std::string to_json(); + std::string to_json() const; }; struct PackageMetadata @@ -73,7 +73,7 @@ namespace vcpkg::Export::Prefab int schema; std::vector dependencies; std::string version; - std::string to_json(); + std::string to_json() const; }; void do_export(const std::vector& export_plan, diff --git a/include/vcpkg/metrics.h b/include/vcpkg/metrics.h index 498a81b3f5..459a418de2 100644 --- a/include/vcpkg/metrics.h +++ b/include/vcpkg/metrics.h @@ -98,24 +98,24 @@ namespace vcpkg Metrics(const Metrics&) = delete; Metrics& operator=(const Metrics&) = delete; - void set_send_metrics(bool should_send_metrics); - void set_print_metrics(bool should_print_metrics); + static void set_send_metrics(bool should_send_metrics); + static void set_print_metrics(bool should_print_metrics); // This function is static and must be called outside the g_metrics lock. static void enable(); - void track_metric(const std::string& name, double value); - void track_buildtime(const std::string& name, double value); + static void track_metric(const std::string& name, double value); + static void track_buildtime(const std::string& name, double value); - void track_define_property(DefineMetric metric); - void track_string_property(StringMetric metric, StringView value); - void track_bool_property(BoolMetric metric, bool value); + static void track_define_property(DefineMetric metric); + static void track_string_property(StringMetric metric, StringView value); + static void track_bool_property(BoolMetric metric, bool value); - void track_feature(const std::string& feature, bool value); + static void track_feature(const std::string& feature, bool value); - bool metrics_enabled(); + static bool metrics_enabled(); - void upload(const std::string& payload); + static void upload(const std::string& payload); void flush(Filesystem& fs); }; diff --git a/include/vcpkg/paragraphparser.h b/include/vcpkg/paragraphparser.h index 610a5acb79..a188584616 100644 --- a/include/vcpkg/paragraphparser.h +++ b/include/vcpkg/paragraphparser.h @@ -57,7 +57,7 @@ namespace vcpkg void required_field(StringView fieldname, std::pair out); std::string optional_field(StringView fieldname); - void optional_field(StringView fieldname, std::pair out); + void optional_field(StringView fieldname, std::pair out) const; void add_type_error(const std::string& fieldname, const char* type) { expected_types[fieldname] = type; } diff --git a/include/vcpkg/xunitwriter.h b/include/vcpkg/xunitwriter.h index eb91cb94dc..6ed17acc38 100644 --- a/include/vcpkg/xunitwriter.h +++ b/include/vcpkg/xunitwriter.h @@ -29,7 +29,7 @@ namespace vcpkg const std::string& abi_tag, const std::vector& features); - std::string build_xml(Triplet controlling_triplet); + std::string build_xml(Triplet controlling_triplet) const; private: std::map> m_tests; diff --git a/src/vcpkg-fuzz/main.cpp b/src/vcpkg-fuzz/main.cpp index 8eeccabff8..c1c6f7d3fa 100644 --- a/src/vcpkg-fuzz/main.cpp +++ b/src/vcpkg-fuzz/main.cpp @@ -98,7 +98,7 @@ namespace // returns {arg, ""} when there isn't an `=` // skips preceding `-`s - std::pair split_arg(StringView arg) + std::pair split_arg(StringView arg) const { auto first = std::find_if(arg.begin(), arg.end(), [](char c) { return c != '-'; }); auto division = std::find(first, arg.end(), '='); @@ -112,7 +112,7 @@ namespace } } - [[noreturn]] void print_help_and_exit(bool invalid = false) + [[noreturn]] void print_help_and_exit(bool invalid = false) const { auto color = invalid ? Color::error : Color::none; diff --git a/src/vcpkg-test/dependencies.cpp b/src/vcpkg-test/dependencies.cpp index 9d4e5fe7ac..1bd3e71bb2 100644 --- a/src/vcpkg-test/dependencies.cpp +++ b/src/vcpkg-test/dependencies.cpp @@ -58,7 +58,7 @@ struct MockVersionedPortfileProvider : IVersionedPortfileProvider SourceControlFileAndLocation& emplace(std::string&& name, Version&& version, - VersionScheme scheme = VersionScheme::String) + VersionScheme scheme = VersionScheme::String) const { #if defined(__cpp_lib_map_try_emplace) && __cpp_lib_map_try_emplace >= 201411 auto it = v.try_emplace(name).first; diff --git a/src/vcpkg-test/expected.cpp b/src/vcpkg-test/expected.cpp index bb49e2ea31..912457914f 100644 --- a/src/vcpkg-test/expected.cpp +++ b/src/vcpkg-test/expected.cpp @@ -17,7 +17,7 @@ namespace std::size_t moves = 0; std::size_t move_assigns = 0; - void check_no_ops() + void check_no_ops() const { CHECK(copies == 0); CHECK(copy_assigns == 0); @@ -76,7 +76,8 @@ namespace ++cr->move_assigns; return *this; } - std::string to_string() const { return "a construct tracker"; } + + static std::string to_string() { return "a construct tracker"; } ~ConstructTracker() { --cr->alive; } }; } diff --git a/src/vcpkg-test/hash.cpp b/src/vcpkg-test/hash.cpp index d0d1bf7a13..0a2c30d87b 100644 --- a/src/vcpkg-test/hash.cpp +++ b/src/vcpkg-test/hash.cpp @@ -60,7 +60,7 @@ using vcpkg::StringView; TEST_CASE ("SHA256: basic tests", "[hash][sha256]") { - const auto algorithm = Hash::Algorithm::Sha256; + constexpr auto algorithm = Hash::Algorithm::Sha256; CHECK_HASH_STRING("", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); CHECK_HASH_STRING(";", "41b805ea7ac014e23556e98bb374702a08344268f92489a02f0880849394a1e4"); @@ -72,11 +72,11 @@ TEST_CASE ("SHA256: basic tests", "[hash][sha256]") TEST_CASE ("SHA256: NIST test cases (small)", "[hash][sha256]") { - const auto algorithm = Hash::Algorithm::Sha256; + constexpr auto algorithm = Hash::Algorithm::Sha256; CHECK_HASH(1, 0xbd, "68325720aabd7c82f30f554b313d0570c95accbb7dc4b5aae11204c08ffe732b"); { - const unsigned char data[] = {0xc9, 0x8c, 0x8e, 0x55}; + constexpr unsigned char data[] = {0xc9, 0x8c, 0x8e, 0x55}; CHECK_HASH_OF(data, "7abc22c0ae5af26ce93dbb94433a0e0b2e119d014f8e7f65bd56c61ccccd9504"); } CHECK_HASH(55, 0, "02779466cdec163811d078815c633f21901413081449002f24aa3e80f0b88ef7"); @@ -90,7 +90,7 @@ TEST_CASE ("SHA256: NIST test cases (small)", "[hash][sha256]") TEST_CASE ("SHA512: NIST test cases (small)", "[hash][sha512]") { - const auto algorithm = Hash::Algorithm::Sha512; + constexpr auto algorithm = Hash::Algorithm::Sha512; CHECK_HASH_STRING("", "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f" diff --git a/src/vcpkg-test/optional.cpp b/src/vcpkg-test/optional.cpp index 1a212b4891..fa1bd15561 100644 --- a/src/vcpkg-test/optional.cpp +++ b/src/vcpkg-test/optional.cpp @@ -97,8 +97,8 @@ TEST_CASE ("optional.map", "[optional]") struct MoveTest { - int operator()(int&&) { return 1; } - int operator()(const int&) { return -1; } + int operator()(int&&) const { return 1; } + int operator()(const int&) const { return -1; } } move_test; Optional dst = std::move(five).map(move_test); diff --git a/src/vcpkg/base/downloads.cpp b/src/vcpkg/base/downloads.cpp index ee80ebb793..173b327503 100644 --- a/src/vcpkg/base/downloads.cpp +++ b/src/vcpkg/base/downloads.cpp @@ -50,7 +50,7 @@ namespace vcpkg return ret; } - ExpectedS query_status() + ExpectedS query_status() const { DWORD dwStatusCode = 0; DWORD dwSize = sizeof(dwStatusCode); diff --git a/src/vcpkg/base/json.cpp b/src/vcpkg/base/json.cpp index 669595f730..88ec78c8c3 100644 --- a/src/vcpkg/base/json.cpp +++ b/src/vcpkg/base/json.cpp @@ -1150,7 +1150,7 @@ namespace vcpkg::Json JsonStyle style; std::string& buffer; - void append_indent(int indent) + void append_indent(int indent) const { if (style.use_tabs()) { @@ -1162,7 +1162,7 @@ namespace vcpkg::Json } }; - void append_unicode_escape(char16_t code_unit) + void append_unicode_escape(char16_t code_unit) const { buffer.append("\\u"); diff --git a/src/vcpkg/base/strings.cpp b/src/vcpkg/base/strings.cpp index 7fd5449388..d5fbb3cf9c 100644 --- a/src/vcpkg/base/strings.cpp +++ b/src/vcpkg/base/strings.cpp @@ -24,7 +24,7 @@ vcpkg::ExpectedL vcpkg::details::api_stable_format_impl(StringView { // Transforms similarly to std::format -- "{xyz}" -> f(xyz), "{{" -> "{", "}}" -> "}" - static const char s_brackets[] = "{}"; + static constexpr char s_brackets[] = "{}"; std::string out; auto prev = sv.begin(); diff --git a/src/vcpkg/base/system.process.cpp b/src/vcpkg/base/system.process.cpp index d04409e851..53cd9d44d9 100644 --- a/src/vcpkg/base/system.process.cpp +++ b/src/vcpkg/base/system.process.cpp @@ -544,7 +544,7 @@ namespace vcpkg friend void swap(ProcessInfo& lhs, ProcessInfo& rhs) noexcept { lhs.swap(rhs); } - unsigned int wait() + unsigned int wait() const { const DWORD result = WaitForSingleObject(proc_info.hProcess, INFINITE); Checks::check_exit(VCPKG_LINE_INFO, result != WAIT_FAILED, "WaitForSingleObject failed"); diff --git a/src/vcpkg/binarycaching.cpp b/src/vcpkg/binarycaching.cpp index b766a9413c..0023f3f4ef 100644 --- a/src/vcpkg/binarycaching.cpp +++ b/src/vcpkg/binarycaching.cpp @@ -1254,7 +1254,7 @@ namespace namespace vcpkg { - LocalizedString UrlTemplate::valid() + LocalizedString UrlTemplate::valid() const { std::vector invalid_keys; auto result = api_stable_format(url_template, [&](std::string&, StringView key) { diff --git a/src/vcpkg/build.cpp b/src/vcpkg/build.cpp index eef675a82b..30be787a1e 100644 --- a/src/vcpkg/build.cpp +++ b/src/vcpkg/build.cpp @@ -486,7 +486,7 @@ namespace vcpkg }); } - const EnvCache::TripletMapEntry& EnvCache::get_triplet_cache(const Filesystem& fs, const Path& p) + const EnvCache::TripletMapEntry& EnvCache::get_triplet_cache(const Filesystem& fs, const Path& p) const { return m_triplet_cache.get_lazy(p, [&]() -> TripletMapEntry { return TripletMapEntry{Hash::get_file_hash(fs, p, Hash::Algorithm::Sha256).value_or_exit(VCPKG_LINE_INFO)}; @@ -657,17 +657,17 @@ namespace vcpkg rc = cmd_execute_and_stream_lines( command, [&](StringView s) { - static const StringLiteral s_hash_marker = "#COMPILER_HASH#"; + static constexpr StringLiteral s_hash_marker = "#COMPILER_HASH#"; if (Strings::starts_with(s, s_hash_marker)) { compiler_info.hash = s.substr(s_hash_marker.size()).to_string(); } - static const StringLiteral s_version_marker = "#COMPILER_CXX_VERSION#"; + static constexpr StringLiteral s_version_marker = "#COMPILER_CXX_VERSION#"; if (Strings::starts_with(s, s_version_marker)) { compiler_info.version = s.substr(s_version_marker.size()).to_string(); } - static const StringLiteral s_id_marker = "#COMPILER_CXX_ID#"; + static constexpr StringLiteral s_id_marker = "#COMPILER_CXX_ID#"; if (Strings::starts_with(s, s_id_marker)) { compiler_info.id = s.substr(s_id_marker.size()).to_string(); @@ -1089,7 +1089,7 @@ namespace vcpkg // If there is an unusually large number of files in the port then // something suspicious is going on. Rather than hash all of them // just mark the port as no-hash - const int max_port_file_count = 100; + constexpr int max_port_file_count = 100; std::string portfile_cmake_contents; std::vector files; diff --git a/src/vcpkg/commands.version.cpp b/src/vcpkg/commands.version.cpp index 36b986207b..7cf5cb4704 100644 --- a/src/vcpkg/commands.version.cpp +++ b/src/vcpkg/commands.version.cpp @@ -18,7 +18,7 @@ namespace namespace vcpkg::Commands::Version { - const StringLiteral version = version_init; + constexpr StringLiteral version = version_init; const CommandStructure COMMAND_STRUCTURE = { create_example_string("version"), 0, diff --git a/src/vcpkg/configuration.cpp b/src/vcpkg/configuration.cpp index 5b3b16f20d..7fc5d4a198 100644 --- a/src/vcpkg/configuration.cpp +++ b/src/vcpkg/configuration.cpp @@ -632,7 +632,7 @@ namespace vcpkg return known_fields; } - void Configuration::validate_as_active() + void Configuration::validate_as_active() const { if (!ce_metadata.is_empty()) { diff --git a/src/vcpkg/dependencies.cpp b/src/vcpkg/dependencies.cpp index d9f4f2db04..a2650fb200 100644 --- a/src/vcpkg/dependencies.cpp +++ b/src/vcpkg/dependencies.cpp @@ -235,7 +235,7 @@ namespace vcpkg .append_raw(m_scfl.error())); } - Optional get_applicable_supports_expression(const FeatureSpec& spec) + Optional get_applicable_supports_expression(const FeatureSpec& spec) const { if (spec.feature() == "core") { @@ -288,11 +288,12 @@ namespace vcpkg void install(Span specs, UnsupportedPortAction unsupported_port_action); void upgrade(Span specs, UnsupportedPortAction unsupported_port_action); - void mark_user_requested(const PackageSpec& spec); + void mark_user_requested(const PackageSpec& spec) const; ActionPlan serialize(GraphRandomizer* randomizer) const; - void mark_for_reinstall(const PackageSpec& spec, std::vector& out_reinstall_requirements); + void mark_for_reinstall(const PackageSpec& spec, + std::vector& out_reinstall_requirements) const; const CMakeVars::CMakeVarProvider& m_var_provider; std::unique_ptr m_graph; @@ -691,7 +692,7 @@ namespace vcpkg return toposort; } - void PackageGraph::mark_user_requested(const PackageSpec& spec) + void PackageGraph::mark_user_requested(const PackageSpec& spec) const { m_graph->get(spec).request_type = RequestType::USER_REQUESTED; } @@ -720,7 +721,7 @@ namespace vcpkg } void PackageGraph::mark_for_reinstall(const PackageSpec& first_remove_spec, - std::vector& out_reinstall_requirements) + std::vector& out_reinstall_requirements) const { std::set removed; std::vector to_remove{first_remove_spec}; diff --git a/src/vcpkg/export.prefab.cpp b/src/vcpkg/export.prefab.cpp index 0c42ca4255..f0338f3866 100644 --- a/src/vcpkg/export.prefab.cpp +++ b/src/vcpkg/export.prefab.cpp @@ -35,13 +35,13 @@ namespace vcpkg::Export::Prefab return paths; } - std::string NdkVersion::to_string() + std::string NdkVersion::to_string() const { std::string ret; this->to_string(ret); return ret; } - void NdkVersion::to_string(std::string& out) + void NdkVersion::to_string(std::string& out) const { out.append("NdkVersion{major=") .append(std::to_string(major())) @@ -90,7 +90,7 @@ namespace vcpkg::Export::Prefab return copy; } - std::string ABIMetadata::to_string() + std::string ABIMetadata::to_string() const { std::string TEMPLATE = R"({ "abi":"@ABI@", @@ -105,7 +105,7 @@ namespace vcpkg::Export::Prefab return json; } - std::string PlatformModuleMetadata::to_json() + std::string PlatformModuleMetadata::to_json() const { std::string TEMPLATE = R"({ "export_libraries": @LIBRARIES@, @@ -117,7 +117,7 @@ namespace vcpkg::Export::Prefab return json; } - std::string ModuleMetadata::to_json() + std::string ModuleMetadata::to_json() const { std::string TEMPLATE = R"({ "export_libraries": [@LIBRARIES@], @@ -131,7 +131,7 @@ namespace vcpkg::Export::Prefab return json; } - std::string PackageMetadata::to_json() + std::string PackageMetadata::to_json() const { std::string deps = jsonify(dependencies); diff --git a/src/vcpkg/install.cpp b/src/vcpkg/install.cpp index 57f8eba886..e87f8521bf 100644 --- a/src/vcpkg/install.cpp +++ b/src/vcpkg/install.cpp @@ -216,8 +216,8 @@ namespace vcpkg bool operator()(const std::string& lhs, const std::string& rhs) { return lhs < rhs; } bool operator()(const file_pack& lhs, const file_pack& rhs) { return lhs.first < rhs.first; } #endif - bool operator()(const std::string& lhs, const file_pack& rhs) { return lhs < rhs.first; } - bool operator()(const file_pack& lhs, const std::string& rhs) { return lhs.first < rhs; } + bool operator()(const std::string& lhs, const file_pack& rhs) const { return lhs < rhs.first; } + bool operator()(const file_pack& lhs, const std::string& rhs) const { return lhs.first < rhs; } }; std::vector intersection; diff --git a/src/vcpkg/paragraphs.cpp b/src/vcpkg/paragraphs.cpp index 902c384ef8..4740c062d4 100644 --- a/src/vcpkg/paragraphs.cpp +++ b/src/vcpkg/paragraphs.cpp @@ -98,7 +98,7 @@ namespace vcpkg else missing_fields.push_back(fieldname.data()); } - void ParagraphParser::optional_field(StringView fieldname, std::pair out) + void ParagraphParser::optional_field(StringView fieldname, std::pair out) const { auto maybe_field = remove_field(&fields, fieldname); if (auto field = maybe_field.get()) out = std::move(*field); diff --git a/src/vcpkg/registries.cpp b/src/vcpkg/registries.cpp index 352aae2fdb..99eb07d29f 100644 --- a/src/vcpkg/registries.cpp +++ b/src/vcpkg/registries.cpp @@ -1206,7 +1206,7 @@ namespace vcpkg { static constexpr struct { - bool operator()(char ch) { return ('0' <= ch && ch <= '9') || ('a' <= ch && ch <= 'f'); } + bool operator()(char ch) const { return ('0' <= ch && ch <= '9') || ('a' <= ch && ch <= 'f'); } } is_lcase_ascii_hex; return sv.size() == 40 && std::all_of(sv.begin(), sv.end(), is_lcase_ascii_hex); diff --git a/src/vcpkg/sourceparagraph.cpp b/src/vcpkg/sourceparagraph.cpp index 49e0eb800b..91ca74d59a 100644 --- a/src/vcpkg/sourceparagraph.cpp +++ b/src/vcpkg/sourceparagraph.cpp @@ -1024,7 +1024,7 @@ namespace vcpkg const vcpkg::Json::Object& obj, vcpkg::SourceParagraph& spgh, vcpkg::Json::Reader& r, - std::unique_ptr& control_file) + std::unique_ptr& control_file) const { for (const auto& el : obj) { diff --git a/src/vcpkg/xunitwriter.cpp b/src/vcpkg/xunitwriter.cpp index 0dfe620f6a..73e61117c1 100644 --- a/src/vcpkg/xunitwriter.cpp +++ b/src/vcpkg/xunitwriter.cpp @@ -110,7 +110,7 @@ void XunitWriter::add_test_results(const PackageSpec& spec, features}); } -std::string XunitWriter::build_xml(Triplet controlling_triplet) +std::string XunitWriter::build_xml(Triplet controlling_triplet) const { XmlSerializer xml; xml.emit_declaration();