std::alignment_of
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. |
| Defined in header <type_traits>
|
||
| template< class T > struct alignment_of; |
(ya que C + +11) | |
Proporciona el miembro constante
value igual al requisito de alineación de la T tipo, como si se obtienen por una expresión alignof. Si T es un tipo de matriz, devuelve los requisitos de alineación del tipo de elemento .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.
You can help to correct and verify the translation. Click here for instructions.
Contenido |
Inherited from std::integral_constant
Member constants
| value [estático] |
alignof(typename std::remove_all_extents<T>::type) (público miembro constante estática) |
Member functions
| operator std::size_t |
convierte el objeto a std::size_t, devuelve 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. (miembro público función) |
Member types
| Tipo
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> |
[editar] Posible implementación
template< class T > struct alignment_of : std::integral_constant< std::size_t, alignof(typename std::remove_all_extents<T>::type) > {}; |
[editar] Ejemplo
#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:
1 4 8
[editar] Ver también
| alignof operator | queries alignment requirements of a type (ya que C + +11) |
| (C++11) |
lo contrario. define el tipo adecuado para su uso como almacenamiento sin inicializar para tipos de tamaño dado 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. (clase de plantilla) |
| (C++11) |
define el tipo adecuado para su uso como almacenamiento sin inicializar todos los tipos dados 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. (clase de plantilla) |
| (C++11) |
Tipo POD con el requisito de alineación tan grande como cualquier otro tipo escalar 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) |