std::is_convertible
De 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. |
| Défini dans l'entête <type_traits>
|
||
| template< class From, class To > struct is_convertible; |
(depuis C++11) | |
Si une rvalue imaginaire de type
From peut être utilisé dans l'instruction de retour d'une fonction renvoyant To, qui est, si elle peut être convertie en utilisant To implicit conversion, fournit du membre de constante égale à value true. Sinon value est 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.
Sommaire |
Inherited from std::integral_constant
Member constants
| value [ statique ]Original: static The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
true si From is convertible to To , false autrement 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. (constante membre statique publique) |
Member functions
| operator bool |
convertit l'objet en bool, retourne 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. (fonction membre publique) |
Member types
| Type d'
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> |
[modifier] Notes
Donne des résultats bien définis pour les types référence, les types, les types de tableaux vides et des types de fonction .
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.
[modifier] Exemple
#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'; }
Résultat :
true false false