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 dynamic_cast<TARGET *>(source.get()). If that would return a shared pointer referring to nothing (0 == get()), then instead return an (empty) default constructed shared pointer. Note that a compiler diagnostic will be emitted indicating an error unless dynamic_cast<TARGET *>(source.get()) is a valid expression..

Synopsis

Declared in <bslstl_sharedptr.h>

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

Created with MrDocs