From fefa7b05c7caa2c02a0a1fdf5f0222b3b5e8fe5b Mon Sep 17 00:00:00 2001 From: Username404 Date: Sat, 18 Sep 2021 15:32:31 +0200 Subject: [PATCH] Take an initializer_list instead of variadic arguments in the nextAre lambda function --- src/headers/parsing/Parser.hpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/headers/parsing/Parser.hpp b/src/headers/parsing/Parser.hpp index e1d6baf..d72f727 100644 --- a/src/headers/parsing/Parser.hpp +++ b/src/headers/parsing/Parser.hpp @@ -4,7 +4,6 @@ #include #include "ParseComponents.hpp" #include "../Yerbacon.hpp" -#include #include namespace Parser { @@ -16,16 +15,14 @@ namespace Parser { using namespace StandardComponents; using enum tok::type; unsigned int i = 0; - const auto nextAre = [&i, &lexed](convertible_to auto nextValues,...) { - va_list argumentsList; - va_start(argumentsList, nextValues); - for (decltype(nextValues) j = 1; j <= nextValues; ++j) { - if (!cmp_greater(lexed.size() - i, nextValues) || lexed[i + j].toktype != va_arg(argumentsList, decltype(nextValues))) { - va_end(argumentsList); + const auto nextAre = [&i, &lexed] T>(const initializer_list& nextValues) { + unsigned int j = 1; + for (const T& nextValue: nextValues) { + if (!cmp_greater(lexed.size() - i, nextValues.size()) || lexed[i + j].toktype != nextValue) { return false; } + ++j; } - va_end(argumentsList); return true; }; for (;i < lexed.size(); ++i) { @@ -40,7 +37,7 @@ namespace Parser { } else throw ParsingException((not next.toktext.empty()) ? '"' + next.toktext + "\" is not a valid class identifier" : "A class identifier is required", next.line); } else { if ((lexed.size() - i) > 2) { - bool isFinalDefine = nextAre(2, TAG, DEFINE); + bool isFinalDefine = nextAre({TAG, DEFINE}); if (isFinalDefine || next.toktype == DEFINE) { parseTree << Define(isFinalDefine, current.toktext); i += 1 + isFinalDefine;