rttrorg / rttr

C++ Reflection Library
https://www.rttr.org
MIT License
3.12k stars 430 forks source link

Issue with registering class hierachies using CRTP #298

Open Illation opened 3 years ago

Illation commented 3 years ago

so considering tihs use case:

// .h
class I_Base
{
    RTTR_ENABLE()
};

template<class TMyType>
class I_CrtpBase : public I_Base
{
    RTTR_ENABLE(I_Base)
};

class MyClass : public I_CrtpBase<MyClass>
{
    RTTR_ENABLE(I_CrtpBase<MyClass>)
}
// .cpp
RTTR_REGISTRATION
{
    rttr::registration::class_<MyClass>("my class");
}

At runtime the code gets stuck during registration, since it tries to create the type for MyClass, then notices it has to create the type for I_CrtpBase<MyClass>, notices the template parameter MyClass and tries to create the type for that again. registering I_CrtpBase<MyClass> first has the same result just the other way around.