9
Declarations
[dcl.dcl]
9.12
Attributes
[dcl.attr]
9.12.11
No unique address attribute
[dcl.attr.nouniqueaddr]
1
#
The
attribute-token
no_
unique_
address
specifies that a non-static data member is a potentially-overlapping subobject (
[intro.
object]
)
.
No
attribute-argument-clause
shall be present
.
The attribute may appertain to a non-static data member other than a bit-field
.
2
#
[
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
]
[
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
alloc
could have the same address as
buckets
if their respective types are all empty
.
—
end example
]