From 37119ceb96227b9a0edaa7ade57310a578a83db3 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Tue, 3 Dec 2024 23:02:43 +0000 Subject: [PATCH] Codechange: Detemplatise uint64_t version of GetNextParameters(). This ensures the visitor is not duplicated for the different types pass to GetNextParamters(), which now is only concerned with casting the result. --- src/strings_internal.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/strings_internal.h b/src/strings_internal.h index a5a0609663..38f4cad5f0 100644 --- a/src/strings_internal.h +++ b/src/strings_internal.h @@ -80,16 +80,28 @@ public: * will be read. * @return The next parameter's value. */ - template - T GetNextParameter() + uint64_t GetNextParameter() { struct visitor { uint64_t operator()(const uint64_t &arg) { return arg; } uint64_t operator()(const std::string &) { throw std::out_of_range("Attempt to read string parameter as integer"); } }; - const auto ¶m = GetNextParameterReference(); - return static_cast(std::visit(visitor{}, param.data)); + const auto ¶m = this->GetNextParameterReference(); + return std::visit(visitor{}, param.data); + } + + /** + * Get the next parameter from our parameters. + * This updates the offset, so the next time this is called the next parameter + * will be read. + * @tparam T The return type of the parameter. + * @return The next parameter's value. + */ + template + T GetNextParameter() + { + return static_cast(this->GetNextParameter()); } /**