std::is_trivial
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_trivial; |
(dal C++11) | |
Se
T
è un tipo banale (cioè, un tipo scalare, una classe banalmente copiabile con un costruttore predefinito banale, o matrice di tale tipo / classe, possibilmente cv qualificato), fornisce il membro costante value
true uguali. Per qualsiasi altro tipo, è value
false.Original:
If
T
is a trivial type (that is, a scalar type, a trivially copyable class with a trivial default constructor, or array of such type/class, possibly cv-qualified), 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 a trivial type , false altrimenti Original: true if T is a trivial 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
Solo gli oggetti (compresi gli array) di tipo banale può essere creato da una chiamata a std::malloc.
Original:
Only objects (including arrays) of trivial type may be created by a call to std::malloc.
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] Possibile implementazione
template< class T > struct is_trivial : std::integral_constant< bool, std::is_trivially_copyable<T>::value && std::is_trivially_default_constructible<T>::value > {}; |
[modifica] Esempio
#include <iostream> #include <type_traits> struct A { int m; }; struct B { B() {} }; int main() { std::cout << std::boolalpha; std::cout << std::is_trivial<A>::value << '\n'; std::cout << std::is_trivial<B>::value << '\n'; }
Output:
true false
[modifica] Vedi anche
(C++11) |
checks if a type is trivially copyable (classe template) |