alignof operator (desde C++11)
Da 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. |
Consultas alinhamento requisitos de um tipo
Original:
Queries alignment requirements of a 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.
Índice |
[editar]Sintaxe
alignof( type) | |||||||||
Retorna um objeto do tipo std::size_t.
Original:
Returns an object of type std::size_t.
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.
[editar]Explicação
Retorna o alinhamento em bytes (uma potência inteira de dois) necessário para qualquer instância do
type
dado, que é um ou outro tipo completo, um tipo de matriz, ou um tipo de referência.Original:
Returns alignment in bytes (an integer power of two) required for any instance of the given
type
, which is either complete type, an array type, or a reference 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.
Se o tipo é tipo de referência, o operador retorna o alinhamento de referência tipo, se o tipo é tipo de matriz, exigência de alinhamento do tipo de elemento é retornado.
Original:
If the type is reference type, the operator returns the alignment of referenced type; if the type is array type, alignment requirement of the element type is returned.
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.
Os tipos char, signedchar e unsignedchar ter mais fraco alinhamento (menor) suportado pela implementação.
Original:
The types char, signedchar, and unsignedchar have the weakest (smallest) alignment supported by the implementation.
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.
[editar]Palavras-chave
[editar]Exemplo
#include <iostream> struct Empty {}; struct Foo {int f2;float f1;char c;}; int main(){std::cout<<"alignment of empty class: "<< alignof(Empty)<<'\n'<<"alignment of pointer : "<< alignof(int*)<<'\n'<<"alignment of char : "<< alignof(char)<<'\n'<<"alignment of Foo : "<< alignof(Foo)<<'\n';}
Saída:
alignment of empty class: 1 alignment of pointer : 8 alignment of char : 1 alignment of Foo : 4
[editar]Veja também
alignas especificador | especifica que o armazenamento para a variável devem ser alinhados por (C++11) quantidade específica Original: specifies that the storage for the variable should be aligned by specific amount (C++11) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
(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) |