std::static_pointer_cast, std::dynamic_pointer_cast, std::const_pointer_cast
Aus cppreference.com
< cpp | memory | shared ptr
![]() |
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. |
template< class T, class U > shared_ptr<T> static_pointer_cast( const shared_ptr<U>& r ); |
(1) | (seit C++11) |
template< class T, class U > shared_ptr<T> dynamic_pointer_cast( const shared_ptr<U>& r ); |
(2) | (seit C++11) |
template< class T, class U > shared_ptr<T> const_pointer_cast( const shared_ptr<U>& r ); |
(3) | (seit C++11) |
Wird eine neue Instanz der std::shared_ptr mit einem gegossenen verwaltete Objekt-Typ aus der
r
Managed Objekttyp zurück. Beide intelligente Zeiger wird teilen die Verantwortung für das verwaltete Objekt .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.
: Die resultierende std::shared_ptr Managed Objekt wird durch den Aufruf (in der jeweiligen Reihenfolge) gewonnen werden
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())
(Wenn das Ergebnis der dynamic_cast
ist 0, der zurückgegeben shared_ptr leer) .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 jedem Fall, wenn der Parameter ist eine leere
r
std::shared_ptr das Ergebnis wird eine neue leere std::shared_ptr sein .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.
[Bearbeiten] Parameter
r | - | Der Zeiger zu konvertieren
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. |