Cannot use define_class with a local class
Closed this issue · 0 comments
katzdm commented
The following code should compile:
int main() {
struct S;
static_assert(is_type(define_class(^S, {})));
[[maybe_unused]] S s;
return 0;
}
It currently fails with a message indicating that S
is an unknown type name. As detailed in P2996.md, the implementation of define_class
is fairly hacky; it has to more or less "pretend to be the parser" and mess with scopes and declaration contexts as the parser otherwise would while parsing a class definition. Some nuance of how the parser does its job must be being overlooked.