mardi 17 mars 2015

Trying to understand §7.2/6 in C++14


7.2/6 (C++14):



An enumeration whose underlying type is fixed is an incomplete type from its point of declaration (3.3.2) to immediately after its enum-base (if any), at which point it becomes a complete type. An enumeration whose underlying type is not fixed is an incomplete type from its point of declaration to immediately after the closing } of its enum-specifier, at which point it becomes a complete type.



Take a look at the snippet below (see live example):



enum A{} t; // enum A{} is a complete type (OK)
enum class B:int z; // enum class B:int is not a complete type
int main()
{
}


I understand why B is not a complete type. But, by just looking at the paragraph above, this doesn't seem so clear to me. z is declared right after the enum-base of an enumeration, whose underlying type is fixed, the same way tis declared right after the closing } of the enum-specifier of an enumerator whose underlying type is not fixed.




Aucun commentaire:

Enregistrer un commentaire