c++ - Is in-class enum forward declaration possible? -
this question has answer here:
i know in c++11 it's possible forward declare enum type (if storage type provided) e.g.
enum e : short; void foo(e e); .... enum e : short { value_1, value_2, .... }
but forward declare enum defined within class e.g.
enum foo::e : short; void foo(e e); .... class foo { enum e : short { value_1, value_2, .... } }
is possible in c++11 ?
no, such forward declaration isn't possible. [decl.enum]/5 (bold emphasis mine):
if enum-key followed nested-name-specifier, the enum-specifier shall refer enumeration declared directly in class or namespace nested-name-specifier refers (i.e., neither inherited nor introduced using-declaration), , enum-specifier shall appear in namespace enclosing previous declaration.
(in case nested-name-specifier name of class followed ::
.)
could, though, put enumeration outside , use opaque-enum-declaration.
Comments
Post a Comment