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. |
Las conversiones implícitas se realizan cada vez que una expresión de algún tipo
T1 se utiliza en el contexto de que no acepta ese tipo, pero acepta algunas T2 otro tipo, en particular: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.
- Cuando la expresión se utiliza como argumento cuando se llama a una función que se declara con
T2como parámetro .Original:When the expression is used as the argument when calling a function that is declared withT2as parameter.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Cuando la expresión se utiliza como un operando con un operador que espera
T2Original:When the expression is used as an operand with an operator that expectsT2The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Cuando se inicializa un nuevo objeto de
T2tipo, incluida la declaraciónreturnen una función que devuelveT2.Original:When initializing a new object of typeT2, includingreturnstatement 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. - Cuando se usa la expresión en una declaración
switch(T2es de tipo integral)Original:When the expression is used in aswitchstatement (T2is integral type)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Cuando la expresión se utiliza en una sentencia
ifo un bucle (T2es bool)Original:When the expression is used in anifstatement or a loop (T2is bool)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
El programa está bien formado (compila) sólo si existe una inequívoca' secuencia conversión implícita de
T1 a 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.
Si hay varias sobrecargas de la función o el operador que se llama, después de la secuencia de la conversión implícita se construye a partir de la T1 a la T2 cada disposición, las normas sobrecarga resolución decidir qué sobrecarga se compila .
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, sobrecarga resolución 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.
Contenido |
[editar] Orden de las conversiones
Secuencia de la conversión implícita consiste en lo siguiente, en este orden:
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)
cero o uno estándar conversión secuencia
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)
cero o uno definida por el usuario de conversión
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)
cero o una secuencia de conversión estándar
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.
Al considerar el argumento a un constructor oa una función definida conversión, sólo una secuencia de conversión estándar se permite (por lo demás conversiones definidas por el usuario puede ser eficaz encadenado). Al convertir de un tipo incorporado a otro tipo incorporado, sólo una secuencia de conversión estándar se permite .
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.
Una secuencia de conversión estándar se compone de los siguientes, en este orden:
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)
cero o uno' transformación valori
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)
cero o una promoción numérico o' conversión numérica
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)
cero o uno' cualificación ajuste
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.
A definido por el usuario de conversión consiste en:
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.
@ * @ Cero o un no-explícito un solo argumento del constructor o no explícita llamada función de conversión
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 expresión se dice que es implícitamente convertible a T2 si y sólo si la declaración T2 t=e; está bien formado (se puede compilar), para algunos t inventado temporal. Tenga en cuenta que esto es diferente de T2 t(e), donde constructores explícitos y funciones de conversión, además, se consideraría .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.
Una excepción es la regla anterior es la conversión implícita especial invocada en los siguientes cinco contextos (desde C++11), donde se espera bool tipo:
Original:
One exception is the above rule is the special implicit conversion invoked in the following five contexts (desde 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.
- controlar la expresión de
if,while,forOriginal:controlling expression ofif,while,forThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - los operadores lógicos
!,&&y||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. -
?:el operador condicionalOriginal: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
-
en tales contextos, la secuencia de conversión implícita si se construye la bool t(e); declaración está bien formado. es decir, la explícita función definida por el usuario de conversión, como
explicit T::operator bool() const; se considera. e Tal expresión se dice que es convertible contextualmente a 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.
[editar] LValue transformaciones
LValue transformaciones se aplican cuando el argumento de valor-i (por ejemplo, referencia a un objeto) se utiliza en el contexto donde rvalue (por ejemplo, un número) que se espera .
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.
[editar] Lvalue a DVALOR conversión
A glvalue de cualquier no-función,
T tipo array no se puede convertir implícitamente prvalue del mismo tipo. Si T es un tipo sin clase, esta conversión también elimina CV-calificadores. A menos que se encontró en su contexto sin evaluar (en un operando de sizeof, typeid, noexcept o decltype), esta conversión efectiva contra copia construye un objeto de tipo temporal T utilizando el original glvalue como argumento del constructor, y ese objeto temporal se devuelve como un prvalue . Si el glvalue tiene la std::nullptr_t tipo, el prvalue resultante es la nullptr puntero nulo 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.
[editar] Matriz a la conversión del puntero
Un valor-valor-o de tipo "array de
N T" o "matriz de límite desconocido de T" se puede convertir implícitamente en un prvalue del tipo "puntero a T". El puntero resultante se refiere al primer elemento de la matriz .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.
[editar] Función de puntero
Un valor-de
T tipo de función se puede convertir implícitamente en un puntero prvalue a esa función. Esto no se aplica a las funciones miembro no estáticas porque lvalues que se refieren a las funciones miembro no estáticas no existen .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.
[editar] Promociones numéricos
[editar] Promoción integral
Prvalues de pequeños tipos integrales (tales como char) se pueden convertir a prvalues de grandes tipos integrales (tales como int). En particular, operadores aritméticos no aceptan tipos más pequeños que int como argumentos, y promociones integrales se aplican automáticamente. Esta conversión conserva siempre el valor .
Original:
Prvalues of small integral types (such as char) may be converted to prvalues of larger integral types (such as int). In particular, operadores aritméticos 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.
Las conversiones implícitas siguientes se clasifican como promociones integrales:
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 charsigned shorto se puede convertir en int .Original:signed charorsigned shortcan 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 charunsigned shorto se puede convertir en unsigned int .Original:unsigned charorunsigned shortcan be converted to unsigned int.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
charse puede convertir en int o unsigned int dependiendo del tipo subyacente: signed char o unsigned char (véase más arriba)Original:charcan be converted to int or unsigned int depending on the underlying type: signed char or unsigned char (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_tychar32_tse puede convertir en el primer tipo de la siguiente lista capaces de mantener su rango de valor: int, unsigned int, long, unsigned long, long long, unsigned long long .Original:wchar_t,char16_t, andchar32_tcan be converted to the first type from the following list able to hold their entire value range: int, unsigned int, long, unsigned long, long long, unsigned long long.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Una enumeración' sin ámbito tipo cuyo tipo subyacente no es fijo puede convertirse en el primer tipo de la siguiente lista capaces de mantener su rango de valor: int, unsigned int, long, unsigned long, long long o unsigned long long. Si el rango de valores es mayor, hay promociones integrales se aplican .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, unsigned int, long, unsigned long, long long, or unsigned long long. 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.
-
- Una enumeración' sin ámbito tipo cuyo tipo subyacente se fija puede ser convertido en su tipo promovido subyacente. (desde C++11)Original:An unscoped enumeration type whose underlying type is fixed can be converted to its promoted underlying type. (desde 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 campo de bits' tipo se puede convertir a int si se puede representar rango de valor de el campo de bits, de lo contrario a unsigned int si se puede representar rango de valor de el campo de bits, por lo demás no promociones integrales aplicar .Original:A bitfield type can be converted to int if it can represent entire value range of the bitfield, otherwise to unsigned int 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.
-
- El bool tipo se puede convertir a int con el valor false convertirse 0 y true convertirse 1 .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.
-
[editar] Flotando promoción punto
Un prvalue de float tipo se puede convertir a prvalue de double tipo. El valor no cambia .
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.
[editar] Conversiones numéricas
A diferencia de las promociones, las conversiones numéricas pueden cambiar los valores, con la posible pérdida de precisión .
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.
[editar] Conversiones Integrales
Un prvalue de un tipo entero o de un tipo de enumeración sin ámbito se puede convertir en cualquier tipo entero otra. Si la conversión se encuentra dentro de las promociones integrales, es una promoción y no una conversión .
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 el tipo de destino es sin signo, el valor resultante es el valor del módulo 2n
donde n es el número de bits utilizados para representar el tipo de destino. En la aritmética de complemento a 2 (utilizado en todas las plataformas donde compiladores C + + están disponibles), esta conversión es un no-op, excepto por el truncamiento de si el tipo de destino es pequeño .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 el tipo de destino está firmado, el valor no cambia si la fuente entero se puede representar en el tipo de destino. De lo contrario, el resultado es definido por la implantación .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 el tipo de fuente es bool, la false valor se convierte en cero y el true valor se convierte en el valor del tipo de destino (tenga en cuenta que si el tipo de destino es int, este es un número entero no promoción, una conversión de número entero)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 el tipo de destino es bool, esto es una conversión booleana (ver más abajo)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.
-
[editar] Flotando conversiones de punto
Un prvalue de un tipo de coma flotante se puede convertir en prvalue de cualquier otro tipo de punto flotante. Si la conversión se encuentra dentro de las promociones en punto flotante, es una promoción y no una conversión .
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 el valor de la fuente se puede representar exactamente en el tipo de destino, no cambia .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 el valor de la fuente está entre dos valores representables del tipo de destino, el resultado es uno de esos dos valores (que está definido por la implantación cuál)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.
-
- De lo contrario, el comportamiento es indefinido .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.
-
[editar] Flotante - Las conversiones de enteros
- Un prvalue de tipo de punto flotante se puede convertir en prvalue de cualquier tipo entero. La parte fraccionaria se trunca, es decir, la parte fraccionaria se descarta. Si el valor no puede encajar en el tipo de destino, el comportamiento es indefinido. Si el tipo de destino es bool, esto es una conversión booleana (ver más abajo) .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 tipo de enumeración número entero o sin ámbito se puede convertir en prvalue de cualquier tipo de punto flotante. Si el valor no puede ser representado correctamente, es definir si la aplicación más cercana o superior al valor representable más cercano inferior se seleccionará. Si el valor no puede encajar en el tipo de destino, el comportamiento es indefinido. Si el tipo de fuente es bool, la false valor se convierte en cero, y la true valor se convierte a una .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.
-
[editar] Conversiones puntero
- El puntero nulo' NULL constante o cualquier otro prvalue de tipo integral que evalúa a cero o cualquier prvalue de std::nullptr_t tipo, incluyendo el puntero nulo' nullptr literal, se puede convertir en cualquier tipo de puntero, y es el resultado el valor de puntero nulo de ese tipo. Dicha conversión (conocido como "conversión nulo puntero se permite un tipo de conversión tot cv-calificado como una sola conversión, es decir, no se considera una combinación de calificación numérica y conversiones) .Original:The null pointer constant NULL or any other prvalue of integral type that evaluates to zero or any prvalue of type std::nullptr_t, including the null pointer literal nullptr, 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 puntero a cualquier prvalue (opcionalmente cv-cualificada)
Ttipo de objeto se puede convertir en un puntero a prvalue (idénticamente cv-cualificada) void. SiTno es el tipo de tiempo de ejecución de la punta-a objeto, el puntero resultante se ajusta para que señale al inicio del almacenamiento ocupada por el objeto más derivado. Si el puntero original es un valor de puntero nulo, el resultado es un valor de puntero nulo del tipo destino .Original:A prvalue pointer to any (optionally cv-qualified) object typeTcan be converted to a prvalue pointer to (identically cv-qualified) void. IfTis 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 puntero a una prvalue (opcionalmente cv-cualificada) tipo de clase derivada puede convertirse en prvalue puntero a su clase base accesible, inequívoca (idénticamente cv-cualificada). El resultado de la conversión es un puntero a la clase base subobjeto dentro del objeto puntiagudo-a. El valor de puntero nulo se convierte en el valor de puntero nulo del tipo destino .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.
-
[editar] Puntero a miembro conversiones
- El puntero nulo' NULL constante o cualquier otro prvalue de tipo integral que evalúa a cero o cualquier prvalue de std::nullptr_t tipo, incluyendo el puntero nulo' nullptr literal, se puede convertir en cualquier tipo de puntero a miembro, y el resultado es el valor de puntero nulo de ese tipo. Dicha conversión (conocido como "conversión nulo puntero se permite un tipo de conversión tot cv-calificado como una sola conversión, es decir, no se considera una combinación de calificación numérica y conversiones) .Original:The null pointer constant NULL or any other prvalue of integral type that evaluates to zero or any prvalue of type std::nullptr_t, including the null pointer literal nullptr, 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 puntero a miembro de algún tipo en un
TBclase base se puede convertir en prvalue puntero a miembro de laTmismo tipo en suDclase derivada. SiBes inaccesible, ambigua, o virtual base deDo es una base de alguna base intermedia virtual deD, la conversión no está bien formado (no se compila). El puntero resultante puede dejar de hacer referencia a un objetoD, y se accederá al miembro dentro de la base de subobjetoBde ese objetoD. El valor de puntero nulo se convierte en el valor de puntero nulo del tipo destino .Original:Prvalue pointer to member of some typeTin a base classBcan be converted to prvalue pointer to member of the same typeTin its derived classD. IfBis inaccessible, ambiguous, or virtual base ofDor is a base of some intermediate virtual base ofD, the conversion is ill-formed (won't compile). The resulting pointer can be dereferenced with aDobject, and it will access the member within theBbase subobject of thatDobject. 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.
-
[editar] Conversiones booleanos
Prvalues de tipos enteros, punto flotante, enumeración sin ámbito, puntero y puntero a miembro, se puede convertir en prvalues de bool tipo .
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.
El valor cero (por enumeración integral, de punto flotante, y sin ámbito) y el puntero nulo y los valores nulos puntero a miembro convertirse false. Todos los demás valores a ser 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 tipo, incluyendo
nullptr, se puede convertir en prvalue de bool tipo. El valor resultante es false. (desde C++11)Original:
Prvalue of type std::nullptr_t, including
nullptr, can be converted to prvalue of type bool. The resulting value is false. (desde 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.
[editar] Conversiones de calificación
- Un prvalue de tipo puntero a tipo <div class="t-tr-text">cv-calificadosOriginal: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.Tse puede convertir en prvalue puntero a un mismo tipo más cv-calificadoT(en otras palabras, se puede añadir constness)Original:A prvalue of type pointer tocv-calificados</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.Tcan 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.
-
- A prvalue de tipo puntero a miembro del cv-calificado
Ttipo enXclase se puede convertir en prvalue puntero al miembro de másTtipo cv-calificado en claseX.Original:A prvalue of type pointer to member of cv-qualified typeTin classXcan be converted to prvalue pointer to member of more cv-qualified typeTin classX.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
-
"Más" cv-calificados significa 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.
- Tipo' no calificado se puede convertir en
constOriginal:unqualified type can be converted toconstThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Tipo' no calificado se puede convertir en
volatileOriginal:unqualified type can be converted tovolatileThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Tipo' no calificado se puede convertir en
const volatileOriginal:unqualified type can be converted toconst volatileThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. -
consttipo se puede convertir enconst volatileOriginal:consttype can be converted toconst volatileThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. -
volatiletipo se puede convertir enconst volatileOriginal:volatiletype can be converted toconst volatileThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
-
Para múltiples niveles punteros, las siguientes restricciones:
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.
A
0 calificado puntero a puntero cv1
1 cualificado para ... cv1
n-1 calificado puntero a cv1
n calificado
0 calificado puntero a puntero cv2
1 cualificado para ... cv2
n-1 calificado puntero a cv2
n calificado
P1 puntero multinivel que es cv10 calificado puntero a puntero cv1
1 cualificado para ... cv1
n-1 calificado puntero a cv1
n calificado
T se puede convertir en un P1 puntero multinivel que es cv20 calificado puntero a puntero cv2
1 cualificado para ... cv2
n-1 calificado puntero a cv2
n calificado
T sólo 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.
- El número de
nniveles es el mismo para ambos punterosOriginal:The number of levelsnis 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. - Si hay un const en la calificación cv1
k a cierto nivel (que no sea el nivel cero) de P1, hay una const en la cv2
k mismo nivel de 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. - Si hay un volatile en la calificación cv1
k a cierto nivel (que no sea el nivel cero) de P1, hay una volatile en el mismo 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 en algún nivel
kla CV-calificaciones son diferentes entreP1yP2, entonces debe ser una constante en todos los niveles individual (que no sea de nivel cero) deP2hasta k: cv2
1, cv2
2 ... cv2
k .Original:If at some levelkthe cv-qualifications are different betweenP1andP2, then there must be a const at every single level (other than level zero) ofP2up 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. - Las mismas reglas se aplican a varios niveles punteros a miembros y de niveles múltiples indicadores mixtos en los objetos y punteros a miembros .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. - Nivel cero está dirigido por las reglas para la conversión de calificación no multinivel .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 particular, esto impide la conversión de
T** a const T**, pero la conversión a const T* const* se permite .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.
[editar] El problema bool segura
Hasta la introducción de funciones de conversión explícito en C + +11, diseñar una clase que debe ser utilizable en contextos booleanos (por ejemplo if(obj) { ... presentó un problema: dada una función definida conversión, como T::operator bool() const;, la secuencia de conversión implícita permitido un nivel adicional conversión de secuencia después de dicha llamada de función, lo que significa la bool resultante se podría convertir a int, permitiendo que el código tal como obj << 1; o 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::operator bool() 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.
Una solución temprana para esto se puede ver en std::basic_ios, que define operator! y operator void*()(hasta C++11), de modo que el código como if(std::cin) {... compila porque void* se puede convertir en bool, pero int n = std::cout; no se compila porque void* no se puede convertir en int. Esto todavía permite que el código tonterías como delete std::cout; para compilar, y muchos pre-C + 11 bibliotecas de terceros se han diseñado con un más solución elaborada, conocido como el Safe Bool idiom .
Original:
One early solution for this can be seen in std::basic_ios, which defines operator! and operator void*()(hasta 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.

