alignas specifier
De 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. |
<metanoindex/>
Especifica a exigência de alinhamento de um tipo ou de um objeto.
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.
Sintaxe
alignas( expression )
|
(desde C++11) | ||||||||
alignas( type-id )
|
(desde C++11) | ||||||||
Explicação
O especificador
alignas pode ser aplicado para a declaração de uma variável ou um membro da classe de dados, ou pode ser aplicado para a definição de uma classe / struct / união ou enum.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.
Quando usado em
alignas(expression) forma, e expression é uma expressão integral constante que resulta em um valor positivo, a entidade declarou terá seu conjunto exigência de alinhamento para exatamente o resultado da expression, exceto se ele iria enfraquecer a exigência de alinhamento natural do tipo.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.
Quando usado em
alignas(type) forma, é exactamente equivalente a alignas(alignof(type)), isto é, a exigência de alinhamento da entidade declarada será igual a exigência de alinhamento typeOriginal:
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 typeThe 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.
Notas
alignas(0) não tem efeito.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.
Quando múltiplos
alignas especificadores são aplicados para a mesma variável ou classe, a mais estrita um é usado.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.
A linguagem C define
alignas como um pré-processador de macro no <stdalign.h> cabeçalho, mas em C + + é uma palavra-chave e os cabeçalhos e <stdalign.h> <cstdalign> não definem tais macro. Eles, no entanto, definir o __alignas_is_defined macro constante.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.
Palavras-chave
Exemplo
// 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];
Veja também
| alignof operator | queries alignment requirements of a type (desde C++11) |
(C++11) |
obtém requisitos do tipo de alinhamento 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. (modelo de classe) |