C11 supports anonymous structures, like so:
struct Foo
{
struct
{
size_t x, y;
};
};
struct Foo f;
f.x = 17;
f.y = 42;
Basically, the members of such a struct
are treated as if they were members of the enclosing struct
or union
(recursively, if the enclosing structure was itself anonymous).
What was the rationale for C++11 not also including anonymous structures? They're only uncommonly useful (mostly inside unions, to eliminate the typing of an identifier for the struct
), certainly. But they seem an obvious enough addition to the specification (and one already implemented by many compilers) that surely they must have been discussed, at the very least to preserve compatibility with the C11 standard. So why weren't they added?