Consider my simple example below:
#include
template
class Base
{
public:
static constexpr int y = T::x;
};
class Derive
This probably isn't the answer anyone would be looking for, but I solved the problem by adding a third class:
#include
template
class Base
{
public:
static constexpr int y = T::x;
};
class Data
{
public:
static constexpr int x = 5;
};
class Derived : public Base, public Data {};
int main()
{
std::cout << Derived::y << std::endl;
}
It works as desired, but unfortunately it doesn't really have the benefits of CRTP!