Espaços nominais
Variantes
Acções

std::alignment_of

Da cppreference.com
< cpp‎ | types

 
 
Biblioteca de utilitários
Digite apoio (basic types, RTTI, type traits)
Gerenciamento de memória dinâmica
De tratamento de erros
Utilidades do programa
Variadic funções
Data e hora
Objetos de função
(C++11)
Os operadores relacionais
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
Pares e tuplas
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
Troque, avançar e avançar
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
(C++11)
 
Apoio a tipos
Tipos básicos
Original:
Basic types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Tipos fundamentais
Tipos inteiros de largura fixos (C++11)
Limites numéricos
Original:
Numeric limits
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
C numérico limita interface
Informações de tipo de tempo de execução
Original:
Runtime type information
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Características de tipo
Original:
Type traits
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Principais categorias de tipo
Original:
Primary type categories
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Propriedades de tipo
Original:
Type properties
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
(C++11)
Operações apoiadas
Original:
Supported operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Relacionamentos e consultas de propriedade
Original:
Relationships and property queries
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
alignment_of
(C++11)
(C++11)
(C++11)
Tipo modificações
Original:
Type modifications
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)(C++11)(C++11)
Transformações tipo
Original:
Type transformations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
(C++11)
Digite constantes traço
Original:
Type trait constants
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
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.

Índice

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>

[editar] Possível implementação

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

[editar] 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

[editar] Veja também

alignof operator queries alignment requirements of a type (desde C++11) [edit]
define o tipo adequado para utilização como armazenamento não inicializada para tipos de determinado tamanho
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.

(modelo de classe) [edit]
define o tipo adequado para utilização como armazenamento não inicializados para todos os tipos de 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.

(modelo de classe) [edit]
Tipo POD com exigência de alinhamento tão grande quanto qualquer outro 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) [edit]