std:: bad_typeid
|
Défini dans l'en-tête
<typeinfo>
|
||
|
class
bad_typeid
:
public
std::
exception
|
||
Une exception de ce type est levée lorsque l'opérateur typeid est appliqué à une valeur de pointeur null déréférencée d'un type polymorphe.
Diagramme d'héritage
Table des matières |
Fonctions membres
|
(constructeur)
|
construit un nouvel objet
bad_typeid
(fonction membre publique) |
|
operator=
|
remplace l'objet
bad_typeid
(fonction membre publique) |
|
what
|
retourne la chaîne explicative
(fonction membre publique) |
std::bad_typeid:: bad_typeid
| (1) | ||
|
bad_typeid
(
)
throw
(
)
;
|
(jusqu'à C++11) | |
|
bad_typeid
(
)
noexcept
;
|
(depuis C++11)
(constexpr depuis C++26) |
|
| (2) | ||
|
bad_typeid
(
const
bad_typeid
&
other
)
throw
(
)
;
|
(jusqu'à C++11) | |
|
bad_typeid
(
const
bad_typeid
&
other
)
noexcept
;
|
(depuis C++11)
(constexpr depuis C++26) |
|
Construit un nouvel objet
bad_typeid
avec une chaîne d'octets terminée par un caractère nul définie par l'implémentation, accessible via
what()
.
std::bad_typeid
alors
std::
strcmp
(
what
(
)
, other.
what
(
)
)
==
0
.
(depuis C++11)
Paramètres
| other | - | un autre objet d'exception à copier |
std::bad_typeid:: operator=
|
bad_typeid
&
operator
=
(
const
bad_typeid
&
other
)
throw
(
)
;
|
(jusqu'à C++11) | |
|
bad_typeid
&
operator
=
(
const
bad_typeid
&
other
)
noexcept
;
|
(depuis C++11)
(constexpr depuis C++26) |
|
Assigne le contenu avec celui de
other
.
Si
*
this
et
other
ont tous deux le type dynamique
std::bad_typeid
alors
std::
strcmp
(
what
(
)
, other.
what
(
)
)
==
0
après l'affectation.
(depuis C++11)
Paramètres
| other | - | un autre objet d'exception à assigner |
Valeur de retour
* this
std::bad_typeid:: what
|
virtual
const
char
*
what
(
)
const
throw
(
)
;
|
(jusqu'à C++11) | |
|
virtual
const
char
*
what
(
)
const
noexcept
;
|
(depuis C++11)
(constexpr depuis C++26) |
|
Retourne la chaîne explicative.
Valeur de retour
Pointeur vers une chaîne terminée par un caractère nul, définie par l'implémentation, contenant des informations explicatives. La chaîne est adaptée à la conversion et à l'affichage en tant que std::wstring . Le pointeur est garanti d'être valide au moins jusqu'à la destruction de l'objet exception duquel il est obtenu, ou jusqu'à l'appel d'une fonction membre non constante (par exemple, l'opérateur d'affectation par copie) sur l'objet exception.
|
La chaîne retournée est encodée avec l'encodage littéral ordinaire pendant l'évaluation constante. |
(depuis C++26) |
Notes
Les implémentations sont autorisées mais non obligées de redéfinir
what()
.
Hérité de std:: exception
Fonctions membres
|
[virtual]
|
détruit l'objet exception
(fonction membre publique virtuelle de
std::exception
)
|
|
[virtual]
|
retourne une chaîne explicative
(fonction membre publique virtuelle de
std::exception
)
|
Notes
| Macro de test de fonctionnalité | Valeur | Std | Fonctionnalité |
|---|---|---|---|
__cpp_lib_constexpr_exceptions
|
202411L
|
(C++26) | constexpr pour les types d'exception |
Exemple
Sortie possible :
Attempted a typeid of NULL pointer!