[meta.reflection.layout]
21 Metaprogramming library [meta]
21.4.11 Reflection layout queries [meta.reflection.layout]
struct member_offset {
ptrdiff_t bytes;
ptrdiff_t bits;
constexpr ptrdiff_t total_bits() const;
auto operator<=>(const member_offset&) const = default;
};
constexpr ptrdiff_t member_offset::total_bits() const;
Returns: bytes * CHAR_BIT + bits.
consteval member_offset offset_of(info r);
Let V be the offset in bits from the beginning of a complete object of the type represented by parent_of(r) to the subobject associated with the construct represented by r.
Returns: {V / CHAR_BIT, V % CHAR_BIT}.
Throws: meta::exception unless r represents a non-static data member, unnamed bit-field, or direct base class relationship for which either B is not a virtual base class or D is not an abstract class.
consteval size_t size_of(info r);
Returns: If
- r represents a non-static data member of type T or a data member description or
- dealias(r) represents a type T,
then sizeof(T) if T is not a reference type and size_of(add_pointer(^^T)) otherwise.
Otherwise, size_of(type_of(r)).
Throws: meta::exception unless all of the following conditions are met:
dealias(r) is a reflection of a type, object, value, variable of non-reference type, non-static data member that is not a bit-field, direct base class relationship, or data member description ([class.mem.general]) where W is ⊥.
If dealias(r) represents a type, then is_complete_type(r) is true.
consteval size_t alignment_of(info r);
Returns:
If dealias(r) represents a type T, then alignment_of(add_pointer(r)) if T is a reference type and the alignment requirement of T otherwise.
Otherwise, if dealias(r) represents a variable or object, then the alignment requirement of the variable or object.
Otherwise, if r represents a direct base class relationship, then alignment_of(type_of(r)).
Otherwise, if r represents a non-static data member M of a class C, then the alignment of the direct member subobject corresponding to M of a complete object of type C.
Otherwise, r represents a data member description ([class.mem.general]).
If A is not ⊥, then the value A.
Otherwise, alignment_of(^^T).
Throws: meta::exception unless all of the following conditions are met:
dealias(r) is a reflection of a type, object, variable of non-reference type, non-static data member that is not a bit-field, direct base class relationship, or data member description ([class.mem.general]) where W is ⊥.
If dealias(r) represents a type, then is_complete_type(r) is true.
consteval size_t bit_size_of(info r);
Returns:
If r represents an unnamed bit-field or a non-static data member that is a bit-field with width W, then W.
Otherwise, if r represents a data member description ([class.mem.general]) and W is not ⊥, then W.
Otherwise, CHAR_BIT * size_of(r).
Throws: meta::exception unless all of the following conditions are met: