Implicit conversions
Da cppreference.com.
![]() |
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
Le conversioni implicite vengono eseguite ogni volta che l'espressione di qualche
T1
tipo è usato in un contesto che non accetta quel tipo, ma accetta un certo T2
altro tipo, in particolare: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.
- Quando l'espressione viene usata come argomento quando si chiama una funzione che viene dichiarato con
T2
come parametro.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. - Quando l'espressione viene utilizzata come operando con un operatore che prevede
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. - Quando si inizializza un nuovo oggetto di tipo
T2
, anche in una dichiarazionereturn
T2
funzione che restituisce.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. - Quando l'espressione è usata in un'istruzione
switch
(T2
è tipo integrale)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. - Quando l'espressione è usata in un'istruzione
if
o un loop (T2
è 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.
Il programma è ben formata (compila) solo se esiste un inequivocabile sequenza di conversione implicita da
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.
Se ci sono più overload della funzione o operatore chiamata, dopo la sequenza di conversione implicita è costruita da T1 a T2 ogni disposizione, regole sovraccarico risoluzione decidere quale sovraccarico viene compilato.
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, sovraccarico risoluzione 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.
Indice |
[modifica] Ordine delle conversioni
Sequenza di conversione implicita è così composta, in questo ordine:
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)
zero o uno standard sequenza di conversione
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)
zero o uno definito dall'utente conversione
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)
zero o una sequenza di conversione 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.
Quando si considera l'argomento di un costruttore o ad una funzione definita dall'utente di conversione, solo una sequenza di conversione standard è consentita (in caso contrario conversioni definite dall'utente possono essere efficacemente incatenato). Quando la conversione da un tipo incorporato in un altro tipo incorporato, solo una sequenza conversione standard è permesso.
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 sequenza di conversione standard è così composta, in questo ordine:
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)
zero o uno' trasformazione 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)
zero o una promozione numerico' o conversione numerico
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)
zero o una qualifica' regolazione
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.
Una conversione definita dall'utente composto:
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.
@ * @ Zero o uno non esplicita singolo argomento del costruttore o non esplicita chiamata di funzione di conversione
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
espressione viene detto di essere convertibile in modo implicito T2
se e solo se il T2 t=e; dichiarazione è ben formato (può essere compilato), per qualche t
inventato temporaneo. Si noti che questo è diverso da T2 t(e), dove costruttori espliciti e le funzioni di conversione dovrebbe inoltre essere considerato.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.
L'unica eccezione è la regola di cui sopra è la conversione implicita speciale invocato nei seguenti cinque contesti (dal C++11), in cui si prevede bool Tipo:
Original:
One exception is the above rule is the special implicit conversion invoked in the following five contexts (dal 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.
- espressione di controllo di
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. - gli operatori logici
!
,&&
e||
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. - il
?:
operatore condizionaleOriginal: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
-
in tali contesti, la sequenza di conversione implicita è costruita se la bool t(e); dichiarazione è ben formato. cioè, la funzione di conversione esplicita definita dall'utente come
explicit T::operator bool() const;
è considerato. e
Tale espressione è detto di essere contestualmente convertibile in 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.
[modifica] Lvalue trasformazioni
Lvalue trasformazioni vengono applicate quando l'argomento lvalue (ad esempio riferimento a un oggetto) è utilizzata nel contesto in cui rvalue (ad esempio un numero) è previsto.
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.
[modifica] Lvalue a rvalue conversione
Un glvalue di qualsiasi mancato funzionamento, non di matrice
T
tipo può essere convertito in modo implicito prvalue dello stesso tipo. Se T
non è un tipo di classe, questa conversione elimina anche cv-qualificazione. A meno che incontrate nel contesto non valutata (in un operando di sizeof, typeid, noexcept o decltype), questa conversione in modo efficace copia crea un oggetto temporaneo di tipo T
usando l'originale glvalue come argomento del costruttore, e che oggetto temporaneo viene restituito come un prvalue. Se il glvalue ha il std::nullptr_t tipo, la prvalue risultante è il nullptr
puntatore nullo costante.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.
[modifica] Array alla conversione puntatore
Un "array di
N
T
" lvalue o rvalue di tipo o "matrici di sconosciuto legato di T
" può essere convertito in modo implicito un prvalue di tipo "puntatore a T
". Il puntatore risultante si riferisce al primo elemento della 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.
[modifica] Funzione di puntatore
Un lvalue di
T
funzione tipo può essere convertito implicitamente in un puntatore prvalue a tale funzione. Questo non si applica ai non statici funzioni membro perché lvalue che si riferiscono a non statici funzioni membro non esistono.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.
[modifica] Promozioni numerici
[modifica] Promozione integrale
Prvalues di piccole tipi integrali (come char) possono essere convertiti in prvalues di più tipi integrali (come int). In particolare, operatori aritmetici non accettano tipi più piccolo int come argomenti, e le promozioni integrali vengono applicati automaticamente. Questa conversione mantiene sempre il valore.
Original:
Prvalues of small integral types (such as char) may be converted to prvalues of larger integral types (such as int). In particular, operatori aritmetici 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.
Le seguenti conversioni implicite sono classificati come promozioni integrali:
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
osigned short
può essere convertito in 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
ounsigned short
può essere convertito in unsigned int.Original:unsigned char
orunsigned short
can 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.
char
può essere convertito int o unsigned int seconda del tipo sottostante: signed char o unsigned char (vedi sopra)Original:char
can 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_t
, echar32_t
può essere convertito nel primo tipo dal seguente elenco in grado di tenere l'intera gamma valore: int, unsigned int, long, unsigned long, long long, unsigned long long.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, 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.
- Un'enumerazione senza ambito tipo il cui tipo sottostante non è fisso può essere convertito nel primo tipo dal seguente elenco in grado di tenere l'intera gamma valore: int, unsigned int, long, unsigned long, long long o unsigned long long. Se l'intervallo di valore è maggiore, non si applicano le promozioni integrali.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.
-
- Un'enumerazione' senza ambito tipo cui tipo sottostante è fissato può essere convertito nel suo tipo promosso sottostante. (dal C++11)Original:An unscoped enumeration type whose underlying type is fixed can be converted to its promoted underlying type. (dal C++11)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
-
- A' bitfield tipo può essere convertito int se può rappresentare intera gamma valore del campo di bit, altrimenti unsigned int se può rappresentare intera gamma valore del campo di bit, altrimenti non si applicano promozioni integrali.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.
-
- Il bool tipo può essere convertito in int con il valore false diventando 0 e true diventare 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.
-
[modifica] Floating promozione punto
Un prvalue di float tipo può essere convertito prvalue di double tipo. Il valore non 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.
[modifica] Conversioni numeriche
A differenza delle promozioni, conversioni numeriche possono modificare i valori, con potenziale perdita di precisione.
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.
[modifica] Conversioni integrali
Un prvalue di tipo intero o di un tipo di enumerazione senza ambito possono essere convertiti in qualsiasi altro tipo integer. Se la conversione è elencata sotto promozioni integrali, è una promozione e non una conversione.
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.
- Se il tipo di destinazione è senza segno, il valore risultante è il valore del modulo 2n
n dove è il numero di bit utilizzati per rappresentare il tipo di destinazione. In aritmetica in complemento a 2 (utilizzato su tutte le piattaforme in cui compilatori C + + sono disponibili), questa conversione è un no-op, fatta eccezione per il troncamento se il tipo di destinazione è di piccole dimensioni.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.
-
- Se il tipo di destinazione è firmato, il valore non cambia se l'intero sorgente può essere rappresentato nel tipo di destinazione. In caso contrario, il risultato è l'implementazione definita.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.
-
- Se il tipo di origine è bool, il false valore viene convertito a zero e il true valore viene convertito a quello valore del tipo di destinazione (si noti che se il tipo di destinazione è int, questo è un numero intero non promozione, una conversione intero)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.
-
- Se il tipo di destinazione è bool, questa è una conversione booleana (vedi sotto)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.
-
[modifica] Floating conversioni a virgola
Un prvalue di un tipo a virgola mobile può essere convertito prvalue di qualsiasi altro tipo in virgola mobile. Se la conversione è elencato in virgola mobile promozioni, è una promozione e non una conversione.
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.
- Se il valore di origine può essere rappresentato esattamente nel tipo di destinazione, non 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.
-
- Se il valore di origine è compreso tra due valori rappresentabili del tipo di destinazione, il risultato è uno di questi due valori (si implementazione definita quale)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.
-
- In caso contrario, il comportamento non è definito.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.
-
[modifica] Floating - conversioni integrali
- Un prvalue di tipo a virgola mobile può essere convertito prvalue di qualsiasi tipo intero. La parte frazionaria viene troncata, che è, la parte frazionaria viene scartata. Se il valore non può inserirsi nel tipo di destinazione, il comportamento è indefinito. Se il tipo di destinazione è bool, questa è una conversione booleana (vedi sotto).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 di tipo enumerazione integer o senza ambito possono essere convertiti prvalue di qualsiasi tipo in virgola mobile. Se il valore non può essere rappresentato correttamente, è definita attuazione se il più vicino superiore o il valore più vicino inferiore rappresentabile sarà selezionato. Se il valore non può inserirsi nel tipo di destinazione, il comportamento è indefinito. Se il tipo di origine è bool, il false valore viene convertito a zero, e il true valore viene convertito in uno.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.
-
[modifica] Pointer conversioni
- La'' puntatore nullo costante NULL o qualsiasi altra prvalue di tipo integrale che restituisce zero o qualsiasi prvalue di std::nullptr_t tipo, compreso il puntatore nullo' nullptr letterale, può essere convertito in qualsiasi tipo di puntatore, e il risultato è il valore del puntatore nullo di quel tipo. Tale conversione (noto come nulla di conversione puntatore è permesso di conversione di un tot cv tipo qualificato come una singola conversione, che è, non è considerato una combinazione di numeri e qualificazione conversioni).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 puntatore a qualsiasi prvalue (opzionale cv-qualificata)
T
tipo di oggetto può essere convertito in un puntatore a prvalue (identico cv-qualificata) void.T
se non è il tipo di runtime punte per oggetto, il puntatore risultante viene regolata per indicare l'inizio della memorizzazione occupato dall'oggetto più derivato. Se il puntatore originale è un valore di puntatore nullo, il risultato è un puntatore nullo valore del tipo di destinazione.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 puntatore ad un prvalue (opzionale cv-qualificata) tipo della classe derivata può essere convertito in prvalue puntatore alla relativa classe base accessibile, non ambigua (identico cv-qualificata). Il risultato della conversione è un puntatore alla classe base sotto-oggetto all'interno della punta-di opporsi. Il valore del puntatore nullo viene convertito nel valore puntatore nullo del tipo di destinazione.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.
-
[modifica] Puntatore-a-membro conversioni
- Il puntatore nullo costante NULL o qualsiasi altra prvalue di tipo integrale che restituisce zero o qualsiasi prvalue di std::nullptr_t tipo, tra cui il puntatore nullo letterale nullptr, può essere convertito in qualsiasi puntatore a un membro del tipo e il risultato è il valore di puntatore nullo di quel tipo. Tale conversione (noto come ' nulla di conversione puntatore è permesso di conversione di un tot cv tipo qualificato come una singola conversione, che è, non è considerato una combinazione di numeri e qualificazione conversioni).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.
-
- Puntatore Prvalue al membro di qualche tipo
T
B
in una classe base può essere convertito prvalue puntatore a membro delT
stesso tipo nella suaD
classe derivata. SeB
è inaccessibile, ambiguo, o virtuale base diD
o è una base di qualche base intermedia virtualeD
, la conversione è mal formato (non compilare). Il puntatore risultante può essere referenziato con un oggettoD
, e sarà accedere al membro all'interno del sotto-oggettoB
base di tale oggettoD
. Il valore del puntatore nullo viene convertito nel valore puntatore nullo del tipo di destinazione.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.
-
[modifica] Conversioni booleani
Prvalues di integrali, i tipi in virgola mobile, di enumerazione senza ambito, puntatore e puntatore-a-membro può essere convertito in prvalues di 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.
Il valore zero (per il conteggio integrale, a virgola mobile, e senza ambito) e il puntatore nullo e nulli puntatore-a-membro valori diventano false. Tutti gli altri valori diventano 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 di std::nullptr_t tipo, compresi
nullptr
, può essere convertito prvalue di bool tipo. Il valore risultante è false. (dal C++11)Original:
Prvalue of type std::nullptr_t, including
nullptr
, can be converted to prvalue of type bool. The resulting value is false. (dal 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.
[modifica] Qualificazione conversioni
- Un prvalue di tipo puntatore a tipo <div class="t-tr-text">cv-qualificatoOriginal: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
può essere convertito prvalue puntatore a un tipo più cv qualificatoT
stessa (in altre parole, può essere aggiunto constness)Original:A prvalue of type pointer tocv-qualificato</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 di tipo puntatore a membro del cv qualificati
T
digitareX
classe può essere convertito in prvalue puntatore a membro di più cv qualificatiT
tipo in 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.
-
"More" cv-qualificati significa che
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 qualificato può essere convertito
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. - Tipo qualificato può essere convertito
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. - Tipo qualificato può essere convertito
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. -
const
tipo può essere convertitoconst 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. -
volatile
tipo può essere convertitoconst 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.
-
Per multi-livello puntatori, le seguenti restrizioni:
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 puntatore
0 qualificato puntatore a cv1
1 qualificato puntatore a... cv1
n-1 qualificato puntatore a cv1
n qualificato
0 qualificato puntatore a cv2
1 qualificato puntatore a... cv2
n-1 qualificato puntatore a cv2
n qualificato
P1
multilivello che è cv10 qualificato puntatore a cv1
1 qualificato puntatore a... cv1
n-1 qualificato puntatore a cv1
n qualificato
T
è trasformabile in un P1
puntatore multilivello che è cv20 qualificato puntatore a cv2
1 qualificato puntatore a... cv2
n-1 qualificato puntatore a cv2
n qualificato
T
solo seOriginal:
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.
- Il numero di livelli
n
è la stessa per entrambi i puntatoriOriginal: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. - Se c'è un const nella qualificazione cv1
k ad un certo livello (diverso livello zero) di P1, c'è un const nella cv2
k stesso livello di 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. - Se c'è un volatile nella qualificazione cv1
k ad un certo livello (diverso livello zero) di P1, c'è un volatile nello stesso cv2
klevel di 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. - Se ad un certo livello
k
i cv-qualifiche sono diversi traP1
eP2
, allora ci deve essere un const ad ogni singolo livello (diverso livello zero) diP2
fino 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. - Le stesse regole si applicano a più livelli puntatori ai membri e puntatori miste multi-livello agli oggetti e puntatori ai membri.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. - Livello zero è affrontato le regole per non multilivello conversioni di qualificazione.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.
-
In particolare, questo proibisce la conversione da
T**
a const T**
, ma conversione const T* const*
è consentito.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.
[modifica] Il problema di sicurezza bool
Fino a quando l'introduzione di funzioni di conversione esplicita in C + +11, la progettazione di una classe che dovrebbe essere utilizzabile in contesti booleani (ad esempio if(obj) { ... presentato un problema: data una funzione definita dall'utente conversione, ad esempio T::operator bool() const;, la sequenza di conversione implicita ha permesso uno standard supplementare sequenza di conversione dopo che chiamata di funzione, che significa che il bool risultante potrebbe essere convertito in int, permettendo codice come 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 soluzione presto per questo può essere visto in std::basic_ios, che definisce operator! e operator void*()(fino al c++11), in modo che il codice come if(std::cin) {... compila perché void* è convertibile in bool, ma int n = std::cout; non viene compilato perché void* non è convertibile in int. Ciò consente ancora il codice sciocchezze come delete std::cout; per compilare, e molti pre-C + librerie di terze 11 terzi sono progettati con un soluzione più elaborata, noto come il Safe Bool idiom.
Original:
One early solution for this can be seen in std::basic_ios, which defines operator! and operator void*()(fino al 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.