alignof operator (dal C++11)
Da cppreference.com.
![]() |
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
Richieste allineamento esigenze di un 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.
Indice |
[modifica] Sintassi
alignof( type )
|
|||||||||
Restituisce un oggetto di 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.
[modifica] Spiegazione
Restituisce l'allineamento in byte (una potenza intera di due) richiesto per qualsiasi istanza del
type
data, che può essere di tipo completo, un tipo di matrice, o di un tipo di riferimento.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 il tipo è tipo di riferimento, l'operatore restituisce l'allineamento di riferimento tipo, se il tipo è di tipo array, requisito allineamento del tipo di elemento viene restituito.
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.
I tipi char, signed char e unsigned char hanno più debole (il più piccolo) allineamento supportato dall'implementazione.
Original:
The types char, signed char, and unsigned char 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.
[modifica] Parole chiave
[modifica] Esempio
#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' ; }
Output:
alignment of empty class: 1 alignment of pointer : 8 alignment of char : 1 alignment of Foo : 4
[modifica] Vedi anche
alignas specificatore | specifica che il deposito per la variabile deve essere allineato (C++11) quantità specifica
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) |
ottiene requisiti di allineamento del tipo 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. (classe template) |