Syntax of weak_ptr
The weak_ptr can be declared using the following syntax:
std::weak_ptr<type> name;
where type is the type of data it is pointing to.
weak_ptr in C++
The weak_ptr is one of the smart pointers that provide the capability of a pointer with some reduced risks as compared to the raw pointer. The weak_ptr, just like shared_ptr has the capability to point to the resource owned by another shared_ptr but without owning it. In other words, they are able to create a non-owning reference to the object managed by shared_ptr.
Contact Us