std::alignment_of
Материал из cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Заголовочный файл <type_traits>
|
||
| template< class T > struct alignment_of; |
(начиная с C++11) | |
Обеспечивает постоянный член
value равно требование выравнивания типа T, как бы получить alignof выражение. Если T является типом массива, возвращается требования к выравниванию типа элемента.Original:
Provides the member constant
value equal to the alignment requirement of the type T, as if obtained by an alignof expression. If T is an array type, returns the alignment requirements of the element type.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Содержание |
Унаследован от std::integral_constant
Member constants
| value [static] |
alignof(typename std::remove_all_extents<T>::type) (public static константа-член) |
Member functions
| operator std::size_t |
преобразует объект в std::size_t, возвращает value Original: converts the object to std::size_t, returns value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) |
Member types
| Type
Original: Type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
value_type
|
std::size_t
|
type
|
std::integral_constant<std::size_t, value> |
[править] Возможная реализация
template< class T > struct alignment_of : std::integral_constant< std::size_t, alignof(typename std::remove_all_extents<T>::type) > {}; |
[править] Пример
#include <iostream> #include <type_traits> class A {}; int main() { std::cout << std::alignment_of<A>::value << '\n'; std::cout << std::alignment_of<int>::value << '\n'; std::cout << std::alignment_of<double>::value << '\n'; }
Вывод:
1 4 8
[править] См. также
| alignof operator | queries alignment requirements of a type (начиная с C++11) |
| (C++11) |
определяет тип подходит для использования в качестве неинициализированные для хранения типов заданного размера Original: defines the type suitable for use as uninitialized storage for types of given size The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (шаблон класса) |
| (C++11) |
определяет тип подходит для использования в качестве неинициализированные для хранения всех данных типов Original: defines the type suitable for use as uninitialized storage for all given types The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (шаблон класса) |
| (C++11) |
POD типа с требованием выравнивания так велика, как любой другой тип скаляра Original: POD type with alignment requirement as great as any other scalar type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (определение типа) |