lock3 / meta

122 stars 11 forks source link

cannot iterate through class members with class forward declaration #284

Open zodd-pl opened 3 years ago

zodd-pl commented 3 years ago

In this example https://cppx.godbolt.org/z/jx8Gjn mx member is missing when iterating over class members with forward class declaration of x. I get output:

Compiler stderr
x
y
my

and without class forward declaration of x it works as expected, mx is there.

Compiler stderr
y
my
x
mx
zodd-pl commented 3 years ago

I just found out that i can fix this issue by changing this line: constexpr meta::member_range class_members(i); to: constexpr meta::member_range class_members(meta::type_of(i)); don't why though. Is it a bug of feature ? :)

DarkArc commented 3 years ago

I'd say it's a bug. There are implementations where declarations and entities are not discernible (i.e. implementations where everything is merged into 1 "entity" rather than maintaining forward declarations and definitions separately). Due to that, we really shouldn't be exposing the case:

x
y
my