Namespaces
Variants

std::meta::alignment_of

From cppreference.com
< cpp | meta
Defined in header <meta>
consteval std::size_t alignment_of( std::meta::info r );
(since C++26)

Returns the alignment requirement of the type or (sub)object represented by r.

Parameters

r - a reflection value

Return value

If r represents a type “reference to T”, returns alignof(T*).

Otherwise, if r represents a type U, returns alignof(U).

Otherwise, if r represents a variable or object, returns the alignment requirement of the variable or object.

Otherwise, if r represents a direct base class relationship, returns the alignment requirement of the base class (i.e. std::meta::alignment_of(std::meta::type_of(r))).

Otherwise, if r represents a non-static data member M of a class C, returns the alignment requirement of the corresponding direct member subobject of a complete object of type C.

Otherwise, r represents a data member description, returns its alignment value if not ⊥, or std::meta::alignment_of(std::meta::type_of(r)) otherwise.

Exceptions

Throws std::meta::exception unless all of the following conditions are met:

  • std::meta::dealias(r) represents one of the following:
  • If std::meta::dealias(r) represents a type, std::meta::is_complete_type(r) is true.

Notes

This function treats “reference of T” the same as “pointer to T”. This matches the representation of non-static reference members.

Example

See also

alignof (C++11) queries alignment requirements of a type
(operator)[edit]