When declaring a union, eg
union u
{
int x;
float y;
};
you can construct the union as follows:
u integer { .x = 10 };
u fraction { .y = 10.f };
Suppose I have a pointer to member,
auto union_member_pointer = &u::y;
What syntax allows me to abstractly assign to that member of the union? ie
u unknown { .*union_member_pointer = { } }; // doesn't work
Designated initialization is not permitted to be dynamic. It is applied to the names of members, not of member pointers or anything of the like.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.