How do empty-base optimization and [[no_unique_address]] reduce storage, and what address or layout constraints remain?
Show answer and explanation
A complete empty class object must still have nonzero size so distinct objects can have distinct addresses, but an empty base subobject can often occupy no additional bytes under empty-base optimization. C++20 [[no_unique_address]] allows a non-static data member to be a potentially overlapping subobject, enabling an empty policy member or usable tail padding to share storage when layout rules permit. Neither mechanism guarantees an exact sizeof result for every implementation, and same-type subobjects, alignment, standard-layout rules, ABI choices, and member semantics can require distinct addresses or padding.
A complete empty class object must still have nonzero size so distinct objects can have distinct addresses, but an empty base subobject can often occupy no additional bytes under empty-base optimization. C++20 [[no_unique_address]] allows a non-static data member to be a potentially overlapping subobject, enabling an empty policy member or usable tail padding to share storage when layout rules permit. Neither mechanism guarantees an exact sizeof result for every implementation, and same-type subobjects, alignment, standard-layout rules, ABI choices, and member semantics can require distinct addresses or padding.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.