Load target with a const_cast alias of source.

Synopsis

Declared in <bslstl_sharedptr.h>

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

Description

Load into the specified target an aliased shared pointer sharing ownership of the object managed by the specified source shared pointer and referring to const_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 const_cast<TARGET *>(source.get()) is a valid expression.

Parameters

Name

Description

target

destination shared pointer loaded by the cast

source

source shared pointer that supplies ownership

Created with MrDocs