[dcl.attr.nouniqueaddr] (original) (raw)
[Note 1:
The non-static data member can share the address of another non-static data member or that of a base class, and any padding that would normally be inserted at the end of the object can be reused as storage for other members.
— _end note_]
Recommended practice: The value of a has-attribute-expressionfor the no_unique_address attribute should be 0 for a given implementation unless this attribute can cause a potentially-overlapping subobject to have zero size.
[Example 1: template<typename Key, typename Value,typename Hash, typename Pred, typename Allocator> class hash_map { [[no_unique_address]] Hash hasher;[[no_unique_address]] Pred pred;[[no_unique_address]] Allocator alloc; Bucket *buckets;public: };
Here, hasher, pred, and alloccould have the same address as bucketsif their respective types are all empty.
— _end example_]