std::is_empty
Da cppreference.com.
![]() |
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
Elemento definito nell'header <type_traits>
|
||
template< class T > struct is_empty; |
(dal C++11) | |
Se
T
è en tipo di vuoto (cioè un non-union tipo di classe, senza gli altri membri di po-campi di dimensioni 0, non funzioni virtuali, non classi base virtuali, e non non vuoti classi base non statici), fornisce il membro costante value
true uguali. Per qualsiasi altro 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.
Indice |
Inherited from std::integral_constant
Member constants
value [statico] |
true se T is an empty class type , false altrimenti 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. (pubblico membro statico costante) |
Member functions
operator bool |
converte l'oggetto in bool, restituisce 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. (metodo pubblico) |
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> |
[modifica] Note
sizeof(T) restituisce sempre 1 se
T
è vuoto, ma ereditando dalle classi di base vuote di solito non aumenta la dimensione di una classe grazie all'ottimizzazione di base vuoto.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 tutti i tratti di altro tipo sono classi vuote.
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.
[modifica] Esempio
#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'; }
Output:
true false false
[modifica] Vedi anche
(C++11) |
checks if a type is a class type (but not union type) (classe template) |