[−][src]Trait cpp_core::DynamicCast
Converts a class pointer to a base class pointer.
A null pointer is always converted to a null pointer. If the object can't be converted to the requested type, a null pointer is returned.
It's recommended to perform the conversion by calling dynamic_cast and
dynamic_cast_mut methods on pointer types (CppBox, Ptr, MutPtr, Ref, MutRef)
instead of importing the trait directly.
Provides access to C++ dynamic_cast conversion from base class to derived class.
The conversion in opposite direction can be done with StaticUpcast.
If T1 class is derived (in C++) from T2 class (directly or indirectly),
DynamicCast<T1> is implemented for T2.
The implementation is generated by ritual automatically.
Required methods
unsafe fn dynamic_cast(ptr: Ptr<Self>) -> Ptr<T>
Convert type of a const pointer.
Returns a null pointer if the object doesn't have the requested type.
Safety
This operation is safe as long as ptr is either valid or null.
unsafe fn dynamic_cast_mut(ptr: MutPtr<Self>) -> MutPtr<T>
Convert type of a mutable pointer.
Returns a null pointer if the object doesn't have the requested type.
Safety
This operation is safe as long as ptr is either valid or null.