Daily bit(e) of C++ | std::shared_ptr basics
Daily bit(e) of C++ #420, Basic use of std::shared_ptr in multi-threaded code.
The std::shared_ptr is a powerful yet heavy, ref-counted smart pointer.
Different instances of std::shared_ptr that point to the same block can be safely handled without thread synchronization.
std::shared_ptr is useful for data handoff in multi-threaded code. A producer can relinquish ownership while ensuring that consumers do not lose access to the data.