Implicit conversions
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. |
Les conversions implicites sont effectuées chaque fois que l'expression d'une
T1
type est utilisé dans un contexte qui n'accepte pas ce type, mais accepte certains T2
autre type, en particulier:Original:
Implicit conversions are performed whenever an expression of some type
T1
is used in context that does not accept that type, but accepts some other type T2
, in particular: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.
- Lorsque l'expression est utilisée comme argument lors de l'appel d'une fonction qui est déclarée avec comme paramètre
T2
.Original:When the expression is used as the argument when calling a function that is declared withT2
as parameter.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Lorsque cette expression est utilisée comme un opérande d'un opérateur qui s'attend
T2
Original:When the expression is used as an operand with an operator that expectsT2
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Lors de l'initialisation d'un nouvel objet de
T2
type, y compris la déclarationreturn
dans une fonction retournantT2
.Original:When initializing a new object of typeT2
, includingreturn
statement in a function returningT2
.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Lorsque l'expression est utilisée dans une instruction
switch
(T2
est de type intégral)Original:When the expression is used in aswitch
statement (T2
is integral type)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Lorsque l'expression est utilisée dans une instruction
if
ou une boucle (T2
est bool)Original:When the expression is used in anif
statement or a loop (T2
is bool)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Le programme est bien formé (compile) seulement si il existe une ambiguïté' séquence conversion implicite de
T1
à T2
. Original:
The program is well-formed (compiles) only if there exists one unambiguous implicit conversion sequence from
T1
to T2
. 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.
S'il existe plusieurs surcharges de la fonction ou de l'exploitant est appelé, après la séquence de conversion implicite est construit à partir de T1 à T2 chaque catalogue, qui décide des règles résolution de surcharge surcharge est compilé .
Original:
If there are multiple overloads of the function or operator being called, after the implicit conversion sequence is built from T1 to each available T2, résolution de surcharge rules decide which overload is compiled.
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 |
[modifier]Ordre des conversions
Séquence de conversion implicite compose des éléments suivants, dans cet ordre:
Original:
Implicit conversion sequence consists of the following, in this order:
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.
1)
zéro ou un' standard séquence de conversion
Original:
zero or one standard conversion sequence
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.
2)
zéro ou un' de conversion définie par l'utilisateur
Original:
zero or one user-defined conversion
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.
3)
zéro ou une séquence de conversion standard
Original:
zero or one standard conversion sequence
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.
Lorsque l'on considère l'argument à un constructeur ou à un utilisateur défini par la fonction de conversion, une seule séquence de conversion standard est autorisé (autrement conversions définies par l'utilisateur peuvent être effectivement enchaîné). Lors de la conversion d'un type prédéfini à un autre type intégré, une seule séquence de conversion standard est permis .
Original:
When considering the argument to a constructor or to a user-defined conversion function, only one standard conversion sequence is allowed (otherwise user-defined conversions could be effectively chained). When converting from one built-in type to another built-in type, only one standard conversion sequence is allowed.
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.
Une séquence de conversion standard se compose des éléments suivants, dans cet ordre:
Original:
A standard conversion sequence consists of the following, in this order:
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.
1)
zéro ou un' transformation lvalue
Original:
zero or one lvalue transformation
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.
2)
zéro ou une promotion numérique ou' conversion numérique
Original:
zero or one numeric promotion or numeric conversion
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.
3)
zéro ou un' ajustement de qualification
Original:
zero or one qualification adjustment
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.
Défini par l'utilisateur de conversion se compose de:
Original:
A user-defined conversion consists of:
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.
@ * @ Zéro ou un non explicite unique argument du constructeur ou non explicite appel de la fonction de conversion
Original:
@*@ zero or one non-explicit single-argument constructor or non-explicit conversion function call
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.
Un
e
expression est dite implicitement convertible en T2
si et seulement si la déclaration T2 t=e; est bien formé (peut être compilé), pour certains t
inventé temporaire. Notez que ceci est différent de T2 t(e), où les constructeurs et fonctions explicites de conversion aurait en outre être considérée comme .Original:
An expression
e
is said to be implicitly convertible to T2
if and only if the declaration T2 t=e; is well-formed (can be compiled), for some invented temporary t
. Note that this is different from T2 t(e), where explicit constructors and conversion functions would additionally be considered.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.
La seule exception est la règle ci-dessus est la conversion implicite particulière invoquée au cours des cinq contextes suivants (depuis C++11), où bool type est prévu:
Original:
One exception is the above rule is the special implicit conversion invoked in the following five contexts (depuis C++11), where type bool is expected:
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.
- contrôler l'expression de
if
,while
,for
Original:controlling expression ofif
,while
,for
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - les opérateurs logiques
!
,&&
et||
Original:the logical operators!
,&&
and||
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. ?:
l'opérateur conditionnelOriginal:the conditional operator?:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.static_assert
noexcept
dans de tels contextes, la séquence de conversion implicite est construit si la déclaration bool t(e); est bien formée. à savoir la fonction de conversion explicite défini par l'utilisateur comme
explicit T::operator bool() const;
est considéré. e
Une telle expression est dite contexte convertible en bool .Original:
in such contexts, implicit conversion sequence is built if the declaration bool t(e); is well-formed. that is, the explicit user-defined conversion function such as
explicit T::operator bool() const;
is considered. Such expression e
is said to be contextually convertible to bool.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]Transformations lvalue
Transformations lvalue sont appliquées lorsque l'argument lvalue (par exemple référence à un objet) est utilisée dans un contexte où rvalue (par exemple un nombre) est prévu .
Original:
Lvalue transformations are applied when lvalue argument (e.g. reference to an object) is used in context where rvalue (e.g. a number) is expected.
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]Lvalue rvalue de conversion
Un glvalue de toute non-fonctionnement,
T
type non-tableau peut être converti implicitement en prvalue du même type. Si T
est un type non-classe, cette conversion supprime également cv-qualifications. Sauf rencontrés dans un contexte non évaluée (dans un opérande de sizeof, typeid, noexcept ou decltype), cette conversion efficacement la copie construit un objet temporaire de type T
en utilisant l'original glvalue comme argument du constructeur, et que cet objet temporaire est retourné comme un prvalue . Si le glvalue a le std::nullptr_t type, le prvalue résultant est le pointeur NULL nullptr
constante .Original:
A glvalue of any non-function, non-array type
T
can be implicitly converted to prvalue of the same type. If T
is a non-class type, this conversion also removes cv-qualifiers. Unless encountered in unevaluated context (in an operand of sizeof, typeid, noexcept, or decltype), this conversion effectively copy-constructs a temporary object of type T
using the original glvalue as the constructor argument, and that temporary object is returned as a prvalue. If the glvalue has the type std::nullptr_t, the resulting prvalue is the null pointer constant nullptr
.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]Tableau de conversion pointeur
Une lvalue ou rvalue de type "tableau de
N
T
» ou «tableau de bornes inconnues de T
" peut être implicitement converti en un prvalue de type "pointeur vers T
". Le pointeur de référence résultant du premier élément de la matrice .Original:
A lvalue or rvalue of type "array of
N
T
" or "array of unknown bound of T
" can be implicitly converted to a prvalue of type "pointer to T
". The resulting pointer refers to the first element of the array.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]Fonction de pointeur
Une lvalue de
T
type de fonction peut être implicitement converti en un pointeur prvalue à cette fonction. Ceci ne s'applique pas aux fonctions membres non statiques, car lvalues qui se réfèrent à des fonctions membres non statiques n'existent pas .Original:
An lvalue of function type
T
can be implicitly converted to a prvalue pointer to that function. This does not apply to non-static member functions because lvalues that refer to non-static member functions do not exist.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]Promotions numériques
[modifier]Promotion intégrale
Prvalues de petits types intégraux (comme char) peut être converti en prvalues de grands types intégraux (comme int). En particulier, opérateurs arithmétiques n'acceptons pas les types plus petits que int comme arguments et promotions intégrales sont automatiquement appliquées. Cette conversion conserve toujours la valeur .
Original:
Prvalues of small integral types (such as char) may be converted to prvalues of larger integral types (such as int). In particular, opérateurs arithmétiques do not accept types smaller than int as arguments, and integral promotions are automatically applied. This conversion always preserves the value.
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.
Les conversions implicites suivantes sont classées comme promotions intégrales:
Original:
The following implicit conversions are classified as integral promotions:
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.
signed char
ousigned short
peut être converti en int .Original:signed char
orsigned short
can be converted to int.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
unsigned char
ouunsigned short
peut être converti en unsignedint .Original:unsigned char
orunsigned short
can be converted to unsignedint.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
char
peut être converti en int ou unsignedint selon le type sous-jacent: signedchar ou unsignedchar (voir ci-dessus)Original:char
can be converted to int or unsignedint depending on the underlying type: signedchar or unsignedchar (see above)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
wchar_t
,char16_t
etchar32_t
peut être converti en le premier type dans la liste suivante capables de tenir leur plage de valeur: int, unsignedint, long, unsignedlong, longlong, unsignedlonglong .Original:wchar_t
,char16_t
, andchar32_t
can be converted to the first type from the following list able to hold their entire value range: int, unsignedint, long, unsignedlong, longlong, unsignedlonglong.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Une énumération type sans portée dont le type sous-jacent n'est pas fixe peut être converti en le premier type dans la liste suivante capables de tenir leur plage de valeur: int, unsignedint, long, unsignedlong, longlong ou unsignedlonglong. Si la plage de valeurs est plus grande, pas de promotions intégrales s'appliquent .Original:An unscoped enumeration type whose underlying type is not fixed can be converted to the first type from the following list able to hold their entire value range: int, unsignedint, long, unsignedlong, longlong, or unsignedlonglong. If the value range is greater, no integral promotions apply.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Une énumération' sans portée type dont le type sous-jacent est fixé peut être converti en son type sous-jacent promu. (depuis C++11)Original:An unscoped enumeration type whose underlying type is fixed can be converted to its promoted underlying type. (depuis C++11)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Un type champ de bits peut être converti en int si elle peut représenter plage de valeur du champ de bits, sinon à unsignedint si elle peut représenter plage de valeur du champ de bits, sinon pas de promotions intégrales s'appliquent .Original:A bitfield type can be converted to int if it can represent entire value range of the bitfield, otherwise to unsignedint if it can represent entire value range of the bitfield, otherwise no integral promotions apply.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- La bool type peut être converti en int avec la valeur false devenant de plus en 0 et true1 .Original:The type bool can be converted to int with the value false becoming 0 and true becoming 1.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
[modifier]Flottant promotion de point
Un prvalue de float type peut être converti en prvalue de double type. La valeur ne change pas .
Original:
A prvalue of type float can be converted to prvalue of type double. The value does not change.
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]Conversions numériques
Contrairement aux promotions, les conversions numériques peuvent modifier les valeurs, avec une perte potentielle de précision .
Original:
Unlike the promotions, numeric conversions may change the values, with potential loss of precision.
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]Conversions intégrales
Un prvalue d'un type entier ou d'un type d'énumération sans portée peut être converti en un autre type entier. Si la conversion est répertorié sous promotions intégrales, il s'agit d'une promotion et non une conversion .
Original:
A prvalue of an integer type or of an unscoped enumeration type can be converted to any other integer type. If the conversion is listed under integral promotions, it is a promotion and not a conversion.
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.
- Si le type de destination n'est pas signé, la valeur obtenue est la valeur modulo 2n
où n est le nombre de bits utilisés pour représenter le type de destination. En arithmétique en complément à 2 (utilisé sur toutes les plates-formes où compilateurs C + + sont disponibles), cette conversion est un no-op, à l'exception de la troncature si le type de destination est trop petit .Original:If the destination type is unsigned, the resulting value is the value modulo 2n
where n is the number of bits used to represent the destination type. In 2's complement arithmetic (used on all platforms where C++ compilers are available), this conversion is a no-op, except for the truncation if the destination type is to small.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Si le type de destination est signé, la valeur ne change pas si l'entier source peut être représenté dans le type de destination. Sinon, le résultat est défini par l'implémentation .Original:If the destination type is signed, the value does not change if the source integer can be represented in the destination type. Otherwise the result is implementation-defined.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Si la source est de type bool, le false valeur est convertie à zéro et le true valeur est convertie en une valeur de type de destination (à noter que si le type de destination est int, il s'agit d'une promotion entière, et non une conversion entier)Original:If the source type is bool, the value false is converted to zero and the value true is converted to the value one of the destination type (note that if the destination type is int, this is an integer promotion, not an integer conversion)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Si le type de destination est bool, il s'agit d'une conversion booléen (voir ci-dessous)Original:If the destination type is bool, this is a boolean conversion (see below)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
[modifier]Flottant conversions de points
Un prvalue d'un type à virgule flottante peuvent être convertis en prvalue de tout autre type à virgule flottante. Si la conversion est répertorié sous virgule flottante promotions, il s'agit d'une promotion et non une conversion .
Original:
A prvalue of an floating-point type can be converted to prvalue of any other floating-point type. If the conversion is listed under floating-point promotions, it is a promotion and not a conversion.
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.
- Si la valeur source peut être représentée exactement dans le type de destination, il ne change pas .Original:If the source value can be represented exactly in the destination type, it does not change.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Si la valeur de la source est comprise entre deux valeurs représentables du type de destination, le résultat est une de ces deux valeurs (il est défini par l'implémentation lequel)Original:If the source value is between two representable values of the destination type, the result is one of those two values (it is implementation-defined which one)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Dans le cas contraire, le comportement est indéfini .Original:Otherwise, the behavior is undefined.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
[modifier]Flottant - conversions intégrales
- Un prvalue de type à virgule flottante peuvent être convertis en prvalue de n'importe quel type entier. La partie fractionnaire est tronquée, qui est, la partie fractionnaire est ignorée. Si la valeur ne rentre pas dans le type de destination, le comportement est indéfini. Si le type de destination est bool, il s'agit d'une conversion booléen (voir ci-dessous) .Original:A prvalue of floating-point type can be converted to prvalue of any integer type. The fractional part is truncated, that is, the fractional part is discarded. If the value can not fit into the destination type, the behavior is undefined. If the destination type is bool, this is a boolean conversion (see below).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Un prvalue de type énumération entier ou sans portée peut être converti en prvalue de n'importe quel type à virgule flottante. Si la valeur ne peut pas être représentée correctement, il est défini par l'implémentation de savoir si le plus proche supérieur ou inférieur le plus proche valeur représentable seront sélectionnés. Si la valeur ne rentre pas dans le type de destination, le comportement est indéfini. Si la source est de type bool, la valeur est convertie false à zéro, et la valeur true est convertie en une .Original:A prvalue of integer or unscoped enumeration type can be converted to prvalue of any floating-point type. If the value can not be represented correctly, it is implementation defined whether the closest higher or the closest lower representable value will be selected. If the value can not fit into the destination type, the behavior is undefined. If the source type is bool, the value false is converted to zero, and the value true is converted to one.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
[modifier]Conversions de pointeurs
- Le pointeur nul''NULL constante ou tout autre prvalue de type intégral qui prend la valeur zéro ou un prvalue de std::nullptr_t type, y compris le pointeur null'nullptr littéral, peut être converti en un type de pointeur, et le résultat est la valeur de pointeur null de ce type. Une telle conversion (connu sous le nom pointeur de conversion nul n'est autorisé à conversion tot un type cv-qualifié comme une seule conversion, qui est, il n'est pas considéré comme une combinaison de chiffres et de qualification de conversion) .Original:The null pointer constantNULL or any other prvalue of integral type that evaluates to zero or any prvalue of type std::nullptr_t, including the null pointer literalnullptr, can be converted to any pointer type, and the result is the null pointer value of that type. Such conversion (known as 'null pointer conversion is allowed to conver tot a cv-qualified type as a single conversion, that is, it's not considered a combination of numeric and qualifying conversions).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Un pointeur prvalue à tout (en option cv-qualifié)
T
type d'objet peut être converti en un pointeur à prvalue (identique cv-qualifié) void. SiT
n'est pas le type d'exécution de la pointe à l'objet, le pointeur résultant est ajusté pour pointer vers le début de l'espace de stockage occupé par l'objet le plus dérivé. Si le pointeur d'origine est une valeur de pointeur NULL, le résultat est une valeur de pointeur nul du type de destination .Original:A prvalue pointer to any (optionally cv-qualified) object typeT
can be converted to a prvalue pointer to (identically cv-qualified) void. IfT
is not the runtime type of the pointed-to object, the resulting pointer is adjusted to point to the start of the storage occupied by the most-derived object. If the original pointer is a null pointer value, the result is a null pointer value of the destination type.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Un pointeur prvalue à un (éventuellement qualifié cv) de type classe dérivée peut être converti en prvalue pointeur sur la classe de base accessible, sans ambiguïté (identique cv-qualifié). Le résultat de la conversion est un pointeur sur le sous-objet de classe de base à l'intérieur de l'objet pointu à. La valeur de pointeur null est convertie en la valeur de pointeur nul du type de destination .Original:A prvalue pointer to a (optionally cv-qualified) derived class type can be converted to prvalue pointer to its accessible, unambiguous (identically cv-qualified) base class. The result of the conversion is a pointer to the base class subobject within the pointed-to object. The null pointer value is converted to the null pointer value of the destination type.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
[modifier]Pointeur à membre conversions
- Le pointeur nul''NULL constante ou tout autre prvalue de type intégral qui prend la valeur zéro ou un prvalue de std::nullptr_t type, y compris le pointeur null'nullptr littéral, peut être converti en un type pointeur-à-élément, et le résultat est la valeur de pointeur null de ce type. Une telle conversion (connu sous le nom pointeur de conversion nul n'est autorisé à conversion tot un type cv-qualifié comme une seule conversion, qui est, il n'est pas considéré comme une combinaison de chiffres et de qualification de conversion) .Original:The null pointer constantNULL or any other prvalue of integral type that evaluates to zero or any prvalue of type std::nullptr_t, including the null pointer literalnullptr, can be converted to any pointer-to-member type, and the result is the null pointer value of that type. Such conversion (known as 'null pointer conversion is allowed to conver tot a cv-qualified type as a single conversion, that is, it's not considered a combination of numeric and qualifying conversions).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Prvalue pointeur de membre d'une
T
indiquer unB
classe de base peut être converti en prvalue pointeur vers un membre du même typeT
dans saD
classe dérivée. SiB
est inaccessible, ambiguë ou une base virtuelle deD
ou est une base de certaines de base virtuelle intermédiaire deD
, la conversion est mal formé (ne sera pas compilé). Le pointeur résultant peut être déréférencé avec un objetD
, et il va accéder au membre au sein du sous-objet de baseB
de cet objetD
. La valeur de pointeur null est convertie en la valeur de pointeur nul du type de destination .Original:Prvalue pointer to member of some typeT
in a base classB
can be converted to prvalue pointer to member of the same typeT
in its derived classD
. IfB
is inaccessible, ambiguous, or virtual base ofD
or is a base of some intermediate virtual base ofD
, the conversion is ill-formed (won't compile). The resulting pointer can be dereferenced with aD
object, and it will access the member within theB
base subobject of thatD
object. The null pointer value is converted to the null pointer value of the destination type.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
[modifier]Conversions booléennes
Prvalues de types intégraux, à virgule flottante, énumération sans portée, pointeur, et le pointeur-à-membre peut être converti en prvalues de bool type .
Original:
Prvalues of integral, floating-point, unscoped enumeration, pointer, and pointer-to-member types can be converted to prvalues of type bool.
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.
La valeur zéro (pour le dénombrement intégral, virgule flottante, et sans portée) et le pointeur NULL et les nuls pointeur à membre les valeurs deviennent false. Toutes les autres valeurs deviennent true .
Original:
The value zero (for integral, floating-point, and unscoped enumeration) and the null pointer and the null pointer-to-member values become false. All other values become true.
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.
Prvalue de std::nullptr_t type, y compris
nullptr
, peut être converti en prvalue de bool type. La valeur résultante est false. (depuis C++11)Original:
Prvalue of type std::nullptr_t, including
nullptr
, can be converted to prvalue of type bool. The resulting value is false. (depuis C++11)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]Conversions de qualification
- Un prvalue de type pointeur de type <div class="t-tr-text">cv-qualifiéOriginal:cv-qualifiedThe text has been machine-translated via [http://translate.google.com Google Translate].
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.T
peut être converti en prvalue pointeur vers un type plus cv-qualifié mêmeT
(en d'autres termes, constness peut être ajouté)Original:A prvalue of type pointer tocv-qualifié</div> typeOriginal:cv-qualifiedThe text has been machine-translated via [http://translate.google.com Google Translate].
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.T
can be converted to prvalue pointer to a more cv-qualified same typeT
(in other words, constness can be added)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Un prvalue de type pointeur élément de cv-qualifié
T
type dansX
classe peut être converti en prvalue pointeur vers un membre de plusT
de type CV-qualifié dans la classeX
.Original:A prvalue of type pointer to member of cv-qualified typeT
in classX
can be converted to prvalue pointer to member of more cv-qualified typeT
in classX
.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
«Plus» cv-qualifié signifie que
Original:
"More" cv-qualified means that
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.
- ' Type non qualifié peut être converti en
const
Original:unqualified type can be converted toconst
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - ' Type non qualifié peut être converti en
volatile
Original:unqualified type can be converted tovolatile
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - ' Type non qualifié peut être converti en
const volatile
Original:unqualified type can be converted toconst volatile
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Type
const
peut être converti enconst volatile
Original:const
type can be converted toconst volatile
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Type
volatile
peut être converti enconst volatile
Original:volatile
type can be converted toconst volatile
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Pour le multi-niveau pointeurs, les restrictions suivantes s'appliquent:
Original:
For multi-level pointers, the following restrictions apply:
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.
Un pointeur
0 qualifié pointeur vers cv1
1 qualifié pointeur vers ... cv1
n-1 qualifié pointeur vers cv1
n qualifié
0 pointeur vers cv2
1 qualifié pointeur sur ... cv2
n-1 qualifié pointeur vers cv2
n qualifié
P1
multiniveaux qui est cv10 qualifié pointeur vers cv1
1 qualifié pointeur vers ... cv1
n-1 qualifié pointeur vers cv1
n qualifié
T
est converti en un pointeur P1
multiniveau qui est qualifié cv20 pointeur vers cv2
1 qualifié pointeur sur ... cv2
n-1 qualifié pointeur vers cv2
n qualifié
T
que siOriginal:
A multilevel pointer
0-qualified pointer to cv1
1-qualified pointer to ... cv1
n-1-qualified pointer to cv1
n-qualified
0-qualified pointer to cv2
1-qualified pointer to ... cv2
n-1-qualified pointer to cv2
n-qualified
P1
which is cv10-qualified pointer to cv1
1-qualified pointer to ... cv1
n-1-qualified pointer to cv1
n-qualified
T
is convertible to a multilevel pointer P1
which is cv20-qualified pointer to cv2
1-qualified pointer to ... cv2
n-1-qualified pointer to cv2
n-qualified
T
only ifThe 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.
- Le nombre de niveaux
n
est la même pour les deux pointeursOriginal:The number of levelsn
is the same for both pointersThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - S'il existe une const dans la qualification cv1
k à un certain niveau (autre que le niveau zéro) de P1, il existe un const dans le même niveau de cv2
k P2Original:If there is a const in the cv1
k qualification at some level (other than level zero) of P1, there is a const in the same level cv2
k of P2The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - S'il existe une volatile dans la qualification cv1
k à un certain niveau (autre que le niveau zéro) de P1, il existe un volatile dans le même cv2
klevel de P2Original:If there is a volatile in the cv1
k qualification at some level (other than level zero) of P1, there is a volatile in the same cv2
klevel of P2The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Si à un certain niveau
k
les cv-qualifications sont différentes entreP1
etP2
, il doit y avoir une constante à chaque niveau (autre que le niveau zéro) deP2
jusqu'à k: cv2
1, cv2
2 ... cv2
k .Original:If at some levelk
the cv-qualifications are different betweenP1
andP2
, then there must be a const at every single level (other than level zero) ofP2
up until k: cv2
1, cv2
2 ... cv2
k.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Les mêmes règles s'appliquent à multi-niveaux des pointeurs vers les membres et multi-niveaux mixtes pointeurs vers des objets et des pointeurs vers des membres .Original:Same rules apply to multi-level pointers to members and multi-level mixed pointers to objects and pointers to members.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Niveau zéro est adressée par les règles de qualification pour les conversions non à plusieurs niveaux .Original:Level zero is addressed by the rules for non-multilevel qualification conversions.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
En particulier, ce interdit la conversion de
T**
à const T**
, mais la conversion de const T* const*
est permis .Original:
In particular, this forbids the conversion from
T**
to const T**
, but conversion to const T* const*
is allowed.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]Le problème sécuritaire bool
Jusqu'à l'introduction de fonctions de conversion explicite en C + +11, la conception d'une classe qui devrait être utilisable dans des contextes booléens (par exemple if(obj){ ... a posé un problème: étant donné défini par l'utilisateur Fonction de conversion, comme T::operatorbool()const;, la séquence de conversion implicite a permis une norme supplémentaire séquence de conversion après cet appel de fonction, ce qui signifie que l'bool résultante pourrait être converti en int, permettant un code tel que obj <<1; ou int i=test; .
Original:
Until the introduction of explicit conversion functions in C++11, designing a class that should be usable in boolean contexts (e.g. if(obj){ ... presented a problem: given a user-defined conversion function, such as T::operatorbool()const;, the implicit conversion sequence allowed one additional standard conversion sequence after that function call, which means the resultant bool could be converted to int, allowing such code as obj <<1; or int i=test;.
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.
Une solution rapide pour ce qui peut être vu dans std::basic_ios, qui définit operator! et operator void*() (avant C++11), de sorte que le code comme if(std::cin){... compile parce void* est convertible en bool, mais int n =std::cout; ne compile pas parce void* n'est pas convertible en int. Cela permet encore de code de telles absurdités que delete std::cout; de compiler et de nombreux pré-C + 11 bibliothèques de tiers ont été conçus avec un solution plus élaborée, connue sous le nom Safe Bool idiom .
Original:
One early solution for this can be seen in std::basic_ios, which defines operator! and operator void*() (avant C++11), so that the code such as if(std::cin){... compiles because void* is convertible to bool, but int n =std::cout; does not compile because void* is not convertible to int. This still allows nonsense code such as delete std::cout; to compile, and many pre-C++11 third party libraries were designed with a more elaborate solution, known as the Safe Bool idiom.
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.