In C++11 a type specifier includes class specifiers and enum specifiers. (aka class definitions and enumeration definitions)
According to the grammar/syntax - type specifiers can appear in several places in the language, but not in all those places are class specifiers and enum specifiers allowed.
For example:
struct C{} c;
// ok: types may be defined in the specifiers of a simple declaration
void f(struct S{});
// error: types may not be defined in parameter types
constexpr auto i = sizeof(enum E{});
// error: types may not be defined in ‘sizeof’ expressions
Where in the standard does it partition these uses of type specifiers into those where types may and may not be defined? For example, where is the rule that says types may not be defined in a sizeof expression?
sizeof
at least this can be inferred from theUnary expressions
grammar specified in 5.3/1, but it's not obvious from a cursory look (due to recursive definitions). – Provincialsizeof(type-id)
->type-id
->type-specifer-seq
->type-specifier
->class-specifier
. Appendix A is a grammar summary by the way. Syntactically it is allowed, so there must be some text somewhere that says you can't define a type there. – Maladjusted