std::is_empty
Da 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. |
Definido no cabeçalho <type_traits>
|
||
template< class T > struct is_empty; |
(desde C++11) | |
Se
T
é en tipo de vazio (ou seja, um tipo de classe não-união com nenhum dos membros não-estáticos que não bit-campos de tamanho 0, há funções virtuais, não classes base virtuais, e não classes não vazias de base), fornece o membro constante value
true igual. Para qualquer outro tipo, é value
false.Original:
If
T
is en empty type (that is, a non-union class type with no non-static members other than bit-fields of size 0, no virtual functions, no virtual base classes, and no non-empty base classes), provides the member constant value
equal true. For any other type, value
is false.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.
Índice |
Herdado de std::integral_constant
Member constants
value [estática] |
true se T is an empty class type , false contrário Original: true if T is an empty class type , false otherwise The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (membro estático público constante) |
Member functions
operator bool |
converte o objeto em bool, retorna value Original: converts the object to bool, 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
|
bool
|
type
|
std::integral_constant<bool, value> |
[editar] Notas
sizeof(T) sempre retorna 1 se
T
está vazio, mas herdando de classes base vazias geralmente não aumentar o tamanho de uma classe, devido à otimização de base vazia.Original:
sizeof(T) always returns 1 if
T
is empty, but inheriting from empty base classes usually does not increase the size of a class due to empty base optimization.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.
std::is_empty<T> e todas as características de tipo são outras classes vazias.
Original:
std::is_empty<T> and all other type traits are empty classes.
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.
[editar] Exemplo
#include <iostream> #include <type_traits> struct A {}; struct B { int m; }; struct C { virtual ~C(); }; int main() { std::cout << std::boolalpha; std::cout << std::is_empty<A>::value << '\n'; std::cout << std::is_empty<B>::value << '\n'; std::cout << std::is_empty<C>::value << '\n'; }
Saída:
true false false
[editar] Veja também
(C++11) |
checks if a type is a class type (but not union type) (modelo de classe) |