std::alignment_of
De cppreference.com
<metanoindex/>
<tbody> </tbody>| Definido no cabeçalho <type_traits>
|
||
template< class T > struct alignment_of; |
(desde C++11) | |
Fornece o membro constante
value igual ao requisito de alinhamento do T tipo, tal como se obtém por uma expressão alignof. Se T é um tipo de matriz, retorna os requisitos de alinhamento do 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.
Herdado de std::integral_constant
Member constants
value [estática] |
alignof(typename std::remove_all_extents<T>::type) (membro estático público constante) |
Member functions
operator std::size_t |
converte o objeto em std::size_t, retorna 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. (função pública membro) |
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>
|
Possível implementação
template< class T >
struct alignment_of : std::integral_constant<
std::size_t,
alignof(typename std::remove_all_extents<T>::type)
> {};
|
Exemplo
#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';
}
Saída:
1
4
8
