std::shared_ptr<T>::operatorbool (3) - Linux Manuals
std::shared_ptr<T>::operatorbool: std::shared_ptr<T>::operatorbool
NAME
std::shared_ptr<T>::operatorbool - std::shared_ptr<T>::operatorbool
Synopsis
explicit operator bool() const noexcept;
Checks if *this stores a non-null pointer, i.e. whether get() != nullptr.
Parameters
(none)
Return value
true if *this stores a pointer, false otherwise.
Notes
An empty shared_ptr (where use_count() == 0) may store a non-null pointer accessible by get(), e.g. if it were created using the aliasing constructor.
Example
// Run this code
Output:
See also
get (public member function)