alignas specifier
Материал из 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. |
Определяет выравнивание требований типа или объекта.
Original:
Specifies the alignment requirement of a type or an object.
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.
Содержание |
[править] Синтаксис
alignas( expression )
|
(начиная с C++11) | ||||||||
alignas( type-id )
|
(начиная с C++11) | ||||||||
[править] Объяснение
alignas спецификатора может быть применен к объявлению переменной или членом класса данных, или оно может быть применено к определению класса / структуры / объединения или перечисления.
Original:
The alignas specifier may be applied to the declaration of a variable or a class data member, or it can be applied to the definition of a class/struct/union or enum.
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.
При использовании в форме alignas(expression), и expression является неотъемлемой постоянное выражение, положительное значение, заявленное лицо будет иметь свой набор требований выравнивания точно результат expression, за исключением, если он ослабит естественное требование выравнивания типа.
Original:
When used in form alignas(expression), and expression is an integral constant expression that evaluates to a positive value, the declared entity will have its alignment requirement set to exactly the result of the expression, except if it would weaken the natural alignment requirement of the 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.
При использовании в форме alignas(type), в точности эквивалентен alignas(alignof(type)), то есть выравнивание требованием заявил лицо будет равна выравнивание требований type
Original:
When used in form alignas(type), is exactly equivalent to alignas(alignof(type)), that is, the alignment requirement of the declared entity will be equal the alignment requirement of 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.
[править] Notes
alignas(0) не имеет никакого эффекта.
Original:
alignas(0) has no effect.
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.
Когда несколько alignas спецификаторы применяются к той же переменной или класса, самый строгий из них используется.
Original:
When multiple alignas specifiers are applied to the same variable or class, the strictest one is used.
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.
Язык C определяет alignas как макрос препроцессора в заголовке <stdalign.h>, но в C + + это ключевые слова, заголовки и <stdalign.h> и <cstdalign> не определяют такой макрос. Они, однако, определить макро постоянной __alignas_is_defined.
Original:
The C language defines alignas as a preprocessor macro in the header <stdalign.h>, but in C++ this is a keyword, and the headers <stdalign.h> and <cstdalign> do not define such macro. They do, however, define the macro constant __alignas_is_defined.
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.
[править] Ключевые слова
[править] Пример
// every object of type sse_t will be aligned to 16-byte boundary struct alignas(16) sse_t { float sse_data[4]; }; // the array "cacheline" will be aligned to 128-byte boundary char alignas(128) cacheline[128];
[править] См. также
| alignof operator | queries alignment requirements of a type (начиная с C++11) |
| (C++11) |
получает выравнивания типа требований Original: obtains the type's alignment requirements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (шаблон класса) |