The following looks like a compilation error :
struct : Base { };
Yet when used [1] it seems to work :
#include <iostream>
using namespace std;
template<bool B>
struct A
{
struct : std::integral_constant<bool, B> {
} members;
};
int main()
{
A<true> a;
cout << a.members.value << endl;
return 0;
}
In c++ is it valid for unnamed structures to inherit? Are there any examples where this is userful?
[1] Disclaimer: I'm not pretending the provided example is useful. I rarely use unnamed structs, and when I do they're usually bundling together some built-in member variables, in order to provide a cleaner interface for a class. The question came up from the observation that memberspaces need not be nammed structures