Fix the findById() and findReferenceByName() methods in ParseComponents.hpp since the filter function doesn't actually exist

This commit is contained in:
Username404 2021-09-12 16:45:12 +02:00
parent 2672f33959
commit 33ee011aed
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 10 additions and 10 deletions

View File

@ -59,21 +59,21 @@ public:
inline iterator end() const noexcept { return subComponents.end(); }
inline const_iterator cend() const noexcept { return subComponents.cend(); }
IS_PARSECOMPONENT
auto findById() const {
return subComponents | filter([](unique_ptr<ParseComponent>& it) -> bool {
return it->getId() == typeid(T);
}) | transform([](unique_ptr<ParseComponent>& it) {
return reinterpret_cast<T*>(it.get());
vector<T*> findById() const {
vector<T*> filteredComponents;
for_each(cbegin(), cend(), [&filteredComponents](const unique_ptr<ParseComponent>& it) {
if (it->getId() == typeid(T)) {
filteredComponents.push_back(reinterpret_cast<T*>(it.get()));
}
});
return filteredComponents;
}
IS(StandardComponents::NamedIdentifier)
optional<reference_wrapper<T>> findReferenceByName(const string& name) const {
auto identifiers = findById<T>() | transform([](T* it) {
return ref(static_cast<T&>(*it));
});
auto identifiers = findById<T>();
for (const auto& identifier: identifiers) {
if (identifier.get().getId() == typeid(T) && identifier.get().name == name) {
return make_optional(identifier);
if (identifier->getId() == typeid(T) && identifier->name == name) {
return make_optional(ref(static_cast<T&>(*identifier)));
}
}
return optional<reference_wrapper<T>>();