Automatic counter for derived class / Alternative?
问题 Right now I have two last problem with the first part of my library. And the first one is this thing not possible in C++ without hack (if I want the constexpr version), it's a derived class counter : class FooBase { protected: static int Counter; }; class Foo : public FooBase { public: static const int Type; }; const int Foo::Type = ++FooBase::Counter; struct FooTest : public Foo {}; Must be in a source file: int FooBase::Counter = 0; Why I need this counter? Well I use it as a type and an