Spec-Zone.ru › C++

std::meta::alignment_of

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:
    • type
    • object
    • variable of non-reference type
    • non-static data member that is not a bit-field
    • direct base class relationship
    • data member description whose bit width is ⊥
  • 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)

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/meta/alignment_of

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API