◐ Shell
clean mode source ↗

std::alignment_of – cppreference.com

Aus cppreference.com

<metanoindex/>

<tbody> </tbody>

definiert in Header

<type_traits>

template< class T > struct alignment_of;

(seit C++11)

Bietet das Mitglied konstanten value gleich der Angleichung Voraussetzung des Typs T, als ob durch einen alignof Ausdruck erhalten. Wenn T ein Array-Typ ist, gibt die Ausrichtung Anforderungen der Element-Typ .

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

alignof(typename std::remove_all_extents<T>::type)
(public static Mitglied konstanten)

Member functions

wandelt das Objekt std::size_t, gibt 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.


(öffentliche Elementfunktion)

Member types

Type

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>

Mögliche Implementierung

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

Beispiel

#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';
}

Output:

Siehe auch

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

definiert den Typ für die Verwendung als Speicher für initialisierten Arten von vorgegebener Größ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.


(Klassen-Template) [edit]

definiert die Art geeignet zur Verwendung als Speicher für alle initialisierten gegebenen Typen

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.


(Klassen-Template) [edit]

POD-Typ mit Angleichung Voraussetzung so groß wie alle anderen skalaren Typ

Original:

POD type with alignment requirement as great as any other scalar type

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


(typedef) [edit]