Пространства имён
Варианты
Действия

alignas specifier

Материал из cppreference.com

 
 
Язык С++
Общие темы
Управление программой
Операторы условного выполнения
Операторы повторения
Операторы перехода
Функции
объявление функции
объявление лямбда-функции
шаблон функции
спецификатор inline
спецификаторы исключений (устарело)
спецификатор noexcept (C++11)
Исключения
Пространства имён
объявление пространства имён
псевдонимы пространства имён
Типы
спецификатор decltype (C++11)
Спецификаторы
cv-спецификаторы
спецификаторы продолжительности хранения
спецификатор constexpr (C++11)
спецификатор auto (C++11)
спецификатор alignas (C++11)
Инициализация
Литералы
Выражения
Утилиты
Типы
typedef-объявление
объявление псевдонима типа (C++11)
атрибуты (C++11)
Приведения типов
неявные преобразования
const_cast-преобразование
static_cast-преобразование
dynamic_cast-преобразование
reinterpret_cast-преобразование
C-подобное и функциональное приведение типов
Выделение памяти
Классы
Особые свойства классовых функций
Специальные функции-члены
Шаблоны
шаблон класса
шаблон функции
специализация шаблона
упакованные параметры (C++11)
Разное
Ассемблерные вставки
 
Определяет выравнивание требований типа или объекта.
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.

Содержание

[править] Синтаксис

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.
При использовании в форме 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.
При использовании в форме 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.

[править] 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.
Когда несколько 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.
Язык 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.

[править] Ключевые слова

alignas

[править] Пример

// 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) [edit]
получает выравнивания типа требований
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.

(шаблон класса) [edit]