Use std::filter and std::transform instead of the std::ranges library and make the destructor of the Target class virtual
This commit is contained in:
parent
c0966f9650
commit
2b84262ea0
|
@ -8,7 +8,7 @@
|
|||
#include <typeinfo>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <ranges>
|
||||
#include <algorithm>
|
||||
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<ParseComponent>& it) {
|
||||
return subComponents | filter([](unique_ptr<ParseComponent>& it) -> bool {
|
||||
return it->getId() == typeid(T);
|
||||
}) | views::transform([](unique_ptr<ParseComponent>& it) {
|
||||
}) | transform([](unique_ptr<ParseComponent>& it) {
|
||||
return reinterpret_cast<T*>(it.get());
|
||||
});
|
||||
}
|
||||
IS(StandardComponents::NamedIdentifier)
|
||||
optional<reference_wrapper<T>> findReferenceByName(const string& name) const {
|
||||
auto identifiers = findById<T>() | views::transform([](T* it) {
|
||||
auto identifiers = findById<T>() | transform([](T* it) {
|
||||
return ref(static_cast<T&>(*it));
|
||||
});
|
||||
for (const auto& identifier: identifiers) {
|
||||
|
|
|
@ -81,6 +81,7 @@ public:
|
|||
#undef with
|
||||
const bool newLines;
|
||||
explicit Target(const bool newLines): newLines(newLines) {};
|
||||
virtual ~Target() = default;
|
||||
};
|
||||
#undef INCLUDECOMPONENT
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue