Can function-local class be defined in the global scope?
Any C++ class can be first forward declared, and defined only later in the program. Are function-local classes an exception from this rule? Please consider a simplified program: auto f() { struct A { struct B; }; return A{}; } using A = decltype( f() ); struct A::B {}; where struct A::B is only declared inside f(), but defined at the end of the program in the global scope. EDG says that this is not permitted: error: class "A::B" cannot be defined in the current scope GCC crashes with Internal Compiler Error, but both Clang and MSVC accept the program just fine. Online demo Which implementation
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.