std::has_virtual_destructor
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 has_virtual_destructor; | (dal C++11) | |
Se
T
è un tipo con un distruttore virtuale, fornisce l'elemento costante value
true uguali. Per qualsiasi altro tipo, è value
false.Original:
If
T
is a type with a virtual destructor, 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 has a virtual destructor , false altrimenti Original: true if T has a virtual destructor , 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
Se una classe ha un distruttore pubblico virtuale, può essere derivato da, e l'oggetto derivato può essere eliminato senza problemi tramite un puntatore all'oggetto di base (C++FAQ Lite 20.7)
Original:
If a class has a public virtual destructor, it can be derived from, and the derived object can be safely deleted through a pointer to the base object (C++FAQ Lite 20.7)
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>#include <string>#include <stdexcept> int main(){std::cout<<std::boolalpha<<"std::string has a virtual destructor? "<< std::has_virtual_destructor<std::string>::value<<'\n'<<"std::runtime_error has a virtual destructor? "<< std::has_virtual_destructor<std::runtime_error>::value<<'\n';}
Output:
std::string has a virtual destructor? false std::runtime_error has a virtual destructor? true
[modifica]Vedi anche
(C++11) (C++11) (C++11) | Verifica se un tipo ha un distruttore non cancellato Original: checks if a type has a non-deleted destructor The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe template) |