std::is_convertible
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 From, class To > struct is_convertible; |
(dal C++11) | |
Se un rvalue immaginaria di tipo
From
può utilizzato nella comunicazione di ritorno di una funzione che restituisce To
, cioè, se può essere convertito To
utilizzando implicit conversion, fornisce il membro costante value
uguale true. In caso contrario, è value
false.Original:
If an imaginary rvalue of type
From
can used in the return statement of a function returning To
, that is, if it can be converted to To
using implicit conversion, provides the member constant value
equal to true. Otherwise 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 From is convertible to To , false altrimenti Original: true if From is convertible to To , 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
Dà risultati ben definiti per i tipi di riferimento, tipi di vuoti, di matrice, e tipi di funzioni.
Original:
Gives well-defined results for reference types, void types, array types, and function types.
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> int main() { class A {}; class B: public A {}; class C {}; bool b2a = std::is_convertible<B*, A*>::value; bool a2b = std::is_convertible<A*, B*>::value; bool b2c = std::is_convertible<B*, C*>::value; std::cout << std::boolalpha; std::cout << b2a << '\n'; std::cout << a2b << '\n'; std::cout << b2c << '\n'; }
Output:
true false false