X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgame%2Freflection.h;fp=source%2Fgame%2Freflection.h;h=6d8535dec003e5d8d7ef3449ecc3ca01dea4dbaf;hb=3643555f600e4580059f75032135ee4f452cf18b;hp=df974b113d3f32a22a1b1b36227d4be654a0193b;hpb=c71b8c2151e097f435c8f76ffa123cc71f9d12ec;p=libs%2Fgame.git diff --git a/source/game/reflection.h b/source/game/reflection.h index df974b1..6d8535d 100644 --- a/source/game/reflection.h +++ b/source/game/reflection.h @@ -93,8 +93,10 @@ private: std::vector>::const_iterator lower_bound(const std::type_index &) const; public: + ClassBase *find_class(const std::type_index &) const; + template - Class *find_class() const; + Class *find_class() const { return static_cast *>(find_class(typeid(T))); } template Class &get_or_create_class(); @@ -109,14 +111,6 @@ inline std::vector>::const_iterator Reflector::lower_ return std::ranges::lower_bound(classes, type, {}, [](auto &c){ return c->get_type(); }); } -template -inline Class *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 *>(i->get()) : nullptr); -} - template inline Class &Reflector::get_or_create_class() {