Fix the findByName function.

This commit is contained in:
Username404 2021-08-08 14:59:47 +02:00
parent fa546865a0
commit dd223026a0
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 5 additions and 4 deletions

View File

@ -52,10 +52,11 @@ protected:
public: public:
IS(StandardComponents::NamedIdentifier) IS(StandardComponents::NamedIdentifier)
optional<reference_wrapper<T>> findByName(const string& name) { optional<reference_wrapper<T>> findByName(const string& name) {
auto identifiers = findById<StandardComponents::NamedIdentifier>(); auto identifiers = findById<T>();
for (const auto& identifier: identifiers) { for (auto&& identifier: identifiers) {
if (identifier.name == name) { if (identifier.getId() == typeid(T) && identifier.name == name) {
return identifier; return make_optional(reference_wrapper<T>(identifier));
break;
} }
} }
return optional<reference_wrapper<T>>(); return optional<reference_wrapper<T>>();