Ive got a code that looks like this
template <class TDerived>
struct Event
{
inline static std::string eventId = typeid(TDerived).name();
};
struct Derived : public Event<Derived>
{
Derived() = default;
};
This compiles correctly in GNU C++, Apple Clang and even MingW in Windows).
But in windows using Visual Studio compiler (MSVC) I am getting the following error
error C2027: use of undefined type 'Derived'
message : see declaration of 'Derived'
message : see reference to class template instantiation 'Event<Derived>' being compiled
I understand that Derived is incomplete at the scope of Event, but why does other compiler can succesfuly recognize it?
Is there any workaround for it to work on VS C++?
my environment
Visual Studio Community 2019
The CXX compiler identification is MSVC 19.28.29336.0
Please help, this kind of line is rampant on what I am porting right now and changing them will be a huge effort.
Reported to Microsoft:
https://developercommunity2.visualstudio.com/t/typeid-with-template-differs-in-behaviou/1323822