Having a brain fart... Is it possible to make something like this work?
template struct Foo
{
template struct Bar;
};
template
Here's what I've been doing, which I think is simpler/more inline with what you're trying to do:
With Helper
template struct Foo
{
template struct Bar__;
template using Bar = Bar__;
};
template template struct Foo::Bar__
{
// general case
const static int x = 0;
};
template template struct Foo::Bar__
{
const static int x = 1;
};
int main(int argc, const char * argv[])
{
std::cout << Foo<1>::Bar<0>::x << "\r\n"; // general case - output 0
std::cout << Foo<1>::Bar<1>::x << "\r\n"; // specialized case - output 1
return 0;
}
OR - The helper can be removed if you don't mind doubling the specialization every time:
Without Helper
template struct Foo
{
template struct Bar;
};
template template struct Foo::Bar
{
// general case
const static int x = 0;
};
template template struct Foo::Bar
{
const static int x = 1;
};
int main(int argc, const char * argv[])
{
std::cout << Foo<1>::Bar<0, 0>::x << "\r\n"; // general case - output 0
std::cout << Foo<1>::Bar<1, 1>::x << "\r\n"; // specialized case - output 1
return 0;
}