I think this is not possible, but I would like to ask you before giving up on this.
I want something like a constexpr increment.
#include <iostream> constexpr int inc() { static int inc = 0; return inc++; } class Foo { static const int Type = inc(); }; class Foo2 { static const int Type = inc(); }; int main() { std::cout << "Foo1 " << Foo1::Type << st::endl; std::cout << "Foo2 " << Foo2::Type << st::endl; return 0; }
I do not want to name it in some classes manually (for this I use CRTP) to give each of them its own type, but the type must be const. Anyway, to achieve something similar in C ++? (C ++ 17 + TS)
c ++ metaprogramming constexpr
Mathieu van nevel
source share