return ranges::any_of(other.bases, [this](const ClassBase *b){ return is_base_of(*b); });
}
+
+ClassBase *Reflector::find_class(const type_index &type) const
+{
+ auto i = lower_bound(type);
+ return (i!=classes.end() && (*i)->get_type()==type ? i->get() : nullptr);
+}
+
} // namespace Reflection
} // namespace Msp::Game
std::vector<std::unique_ptr<ClassBase>>::const_iterator lower_bound(const std::type_index &) const;
public:
+ ClassBase *find_class(const std::type_index &) const;
+
template<typename T>
- Class<T> *find_class() const;
+ Class<T> *find_class() const { return static_cast<Class<T> *>(find_class(typeid(T))); }
template<typename T>
Class<T> &get_or_create_class();
return std::ranges::lower_bound(classes, type, {}, [](auto &c){ return c->get_type(); });
}
-template<typename T>
-inline Class<T> *Reflector::find_class() const
-{
- std::type_index type = typeid(T);
- auto i = lower_bound(type);
- return (i!=classes.end() && (*i)->get_type()==type ? static_cast<Class<T> *>(i->get()) : nullptr);
-}
-
template<typename T>
inline Class<T> &Reflector::get_or_create_class()
{