staticCast overloads

Synopses

Declared in <bslstl_sharedptr.h>

Return a bsl::shared_ptr<TARGET> object sharing ownership of the same object as the specified source shared pointer to the (template parameter) SOURCE type, and referring to static_cast<TARGET *>(source.get()). Note that a compiler diagnostic will be emitted indicating an error unless static_cast<TARGET *>(source.get()) is a valid expression.

template<
    class TARGET,
    class SOURCE>
static
bsl::shared_ptr<TARGET>
staticCast(bsl::shared_ptr<SOURCE> const& source) noexcept;

Load into the specified target an aliased shared pointer sharing ownership of the object managed by the specified source shared pointer and referring to static_cast<TARGET *>(source.get()). If *target is already managing a (possibly shared) object, then release the shared reference to that object, and destroy it using its associated deleter if that shared pointer held the last shared reference to that object. Note that a compiler diagnostic will be emitted indicating an error unless static_cast<TARGET *>(source.get()) is a valid expression.

template<
    class TARGET,
    class SOURCE>
static
void
staticCast(
    bsl::shared_ptr<TARGET>* target,
    bsl::shared_ptr<SOURCE> const& source);

Created with MrDocs