20 Memory management library [mem]

20.3 Pointer tagging [ptrtag]

20.3.2 Class template pointer_tag_pair [ptrtag.pair]

20.3.2.4 Tagged pointer operations [ptrtag.pair.tagops]

using tagged_pointer_type = see below;
tagged_pointer_type denotes cv void*, for cv such that pointer denotes cv U* for some type U.
tagged_pointer_type tagged_pointer() const noexcept;
Returns: An unspecified value tp of tagged_pointer_type type such that for any specialization DP of pointer_tag_pair and alignment value A for which
  • pointer_bits_available(A) >= DP​::​bits_requested is true,
  • is_sufficiently_aligned<A>(ptr) is true, and
  • tag-bit-width(tag) <= DP​::​bits_requested is true,
DP​::​from_tagged(tp) produces an object dp such that reinterpret_cast<pointer_type>(dp.pointer()) is equal to ptr and static_cast<TagT>(dp.tag()) is equal to tag.
[Note 1: 
This function returns an invalid pointer value ([basic.compound]) with implementation-defined behavior.
— end note]
static pointer_tag_pair from_tagged(tagged_pointer_type p) noexcept;
Returns: An object dp of type pointer_tag_type, such that
  • reinterpret_cast<pointer_type>(sp.pointer()) is equal to dp.pointer() and
    static_cast<TagT>(sp.tag()) is equal to dp.tag(), if p is equal to sp.tagged_pointer() for some object sp of a type that is a specialization of pointer_tag_type, such that for some alignment value A
    • pointer_bits_available(A) >= bits_requested is true,
    • is_sufficiently_aligned<A>(sp.pointer()) is true, and
    • tag-bit-width(sp.tag()) <= bits_requested is true,
  • otherwise, the values of dp.pointer() and dp.tag() are unspecified.