◐ Shell
clean mode source ↗

std::alignment_of — cppreference.com

De cppreference.com

<metanoindex/>

<tbody> </tbody>

Déclaré dans l'en-tête

<type_traits>

template< class T > struct alignment_of;

(depuis C++11)

Fournit le membre de constante value égale à l'exigence de l'alignement de la T type, si elle est obtenue par une expression alignof. Si T est un type tableau, renvoie les exigences d'alignement du type d'élément .

Original:

Provides the member constant value equal to the alignment requirement of the type T, as if obtained by an alignof expression. If T is an array type, returns the alignment requirements of the element type.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Inherited from std::integral_constant

Member constants

value

[

statique

Original:

static

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

]

alignof(typename std::remove_all_extents<T>::type)
(constante membre statique publique)

Member functions

convertit l'objet en std::size_t, retourne value

Original:

converts the object to std::size_t, returns value

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(fonction membre publique)

Member types

Type d'

Original:

Type

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Definition
value_type std::size_t
type std::integral_constant<std::size_t, value>

Mise en œuvre possible

template< class T >
struct alignment_of : std::integral_constant<
                          std::size_t,
                          alignof(typename std::remove_all_extents<T>::type)
                       > {};

Exemple

#include <iostream>
#include <type_traits>
 
class A {};
 
int main() 
{
    std::cout << std::alignment_of<A>::value << '\n';
    std::cout << std::alignment_of<int>::value << '\n';
    std::cout << std::alignment_of<double>::value << '\n';
}

Résultat :

Voir aussi

alignof operator queries alignment requirements of a type (depuis C++11) [edit]

définit le type approprié pour une utilisation comme stockage non initialisée pour les types de taille donnée

Original:

defines the type suitable for use as uninitialized storage for types of given size

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(classe générique) [edit]

définit le type approprié pour être utilisé comme stockage non initialisée pour tous les types de données

Original:

defines the type suitable for use as uninitialized storage for all given types

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(classe générique) [edit]

(C++11)

Type de POD avec une exigence d'alignement aussi grand que n'importe quel autre type scalaire
(typedef) [edit]