Hacker News new | past | comments | ask | show | jobs | submit login

> > apparently in C++ a structure cannot really have zero length

> Yes it can: https://en.cppreference.com/w/cpp/language/attributes/no_uni...

A structure with no members can be made to have zero length as a member of something else but not as part of its own definition. I.e., the `[[no_unique_address]]` attribute is a property of the member, not of the struct on its own. It's somewhat annoying that you can't flag an empty struct as being really empty, and have no-unique-address-ness applied everywhere it's used automatically; you have to flag every use with the attribute manually.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: