std::static_pointer_cast, std::dynamic_pointer_cast, std::const_pointer_cast
Da cppreference.com.
< cpp | memory | shared ptr
![]() |
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. |
template< class T, class U > shared_ptr<T> static_pointer_cast( const shared_ptr<U>& r ); |
(1) | (dal C++11) |
template< class T, class U > shared_ptr<T> dynamic_pointer_cast( const shared_ptr<U>& r ); |
(2) | (dal C++11) |
template< class T, class U > shared_ptr<T> const_pointer_cast( const shared_ptr<U>& r ); |
(3) | (dal C++11) |
Può restituire una nuova istanza di std::shared_ptr con un tipo di fuso oggetto gestito dal tipo di oggetto gestito il
r
di. Entrambi i puntatori intelligenti condividerà la proprietà dell'oggetto gestito.Original:
Will return a new instance of std::shared_ptr with a casted managed object type from the
r
's managed object type. Both smart pointers will share the ownership of the managed object.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'oggetto gestito std::shared_ptr risultante sarà ottenuto chiamando il numero (in ordine rispettivamente):
Original:
The resulting std::shared_ptr's managed object will be obtained by calling (in respective 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)
static_cast<T*>(r.get())
.2)
dynamic_cast<T*>(r.get())
(Se il risultato del dynamic_cast
è 0, il shared_ptr restituito sarà vuoto).Original:
dynamic_cast<T*>(r.get())
(If the result of the dynamic_cast
is 0, the returned shared_ptr will be empty).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)
const_cast<T*>(r.get())
.In ogni caso, se il parametro è un
r
std::shared_ptr vuota il risultato sarà una nuova std::shared_ptr vuoto.Original:
In any case, if the parameter
r
is an empty std::shared_ptr the result will be a new empty std::shared_ptr.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] Parametri
r | - | Il puntatore da convertire
Original: The pointer to convert The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |