From 2b84262ea0b41ad12a35d6111f73921a10619a16 Mon Sep 17 00:00:00 2001 From: Username404 Date: Sun, 12 Sep 2021 12:00:21 +0200 Subject: [PATCH] Use std::filter and std::transform instead of the std::ranges library and make the destructor of the Target class virtual --- src/headers/parsing/ParseComponents.hpp | 8 ++++---- src/headers/transpiler/Target.hpp | 1 + src/main.cpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/headers/parsing/ParseComponents.hpp b/src/headers/parsing/ParseComponents.hpp index 8e1bdb3..6ed1f10 100644 --- a/src/headers/parsing/ParseComponents.hpp +++ b/src/headers/parsing/ParseComponents.hpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include using namespace std; #include "../lex.hpp" @@ -60,15 +60,15 @@ public: inline const_iterator cend() const noexcept { return subComponents.cend(); } IS_PARSECOMPONENT auto findById() const { - return subComponents | views::filter([](unique_ptr& it) { + return subComponents | filter([](unique_ptr& it) -> bool { return it->getId() == typeid(T); - }) | views::transform([](unique_ptr& it) { + }) | transform([](unique_ptr& it) { return reinterpret_cast(it.get()); }); } IS(StandardComponents::NamedIdentifier) optional> findReferenceByName(const string& name) const { - auto identifiers = findById() | views::transform([](T* it) { + auto identifiers = findById() | transform([](T* it) { return ref(static_cast(*it)); }); for (const auto& identifier: identifiers) { diff --git a/src/headers/transpiler/Target.hpp b/src/headers/transpiler/Target.hpp index ce8fb59..867cd4e 100644 --- a/src/headers/transpiler/Target.hpp +++ b/src/headers/transpiler/Target.hpp @@ -81,6 +81,7 @@ public: #undef with const bool newLines; explicit Target(const bool newLines): newLines(newLines) {}; + virtual ~Target() = default; }; #undef INCLUDECOMPONENT diff --git a/src/main.cpp b/src/main.cpp index befce84..afdc3e2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,7 +30,7 @@ int main(int argc, char* argv[]) { else if (currentArg == Argument("newlinesoff")) newLines = false; else if (currentArg.ends_with(".ybcon")) files.push_back(currentArg); } - const auto compile = [&target, &newLines](string_view name) { + const auto compile = [&target, &newLines](string_view name) -> string { string transpiledString = transpile(parseString(getFileContent(name.data())), target, newLines); name.remove_suffix(6); string outputFile;