just read it
smart_ptr:https://mbevin.wordpress.com/2012/11/18/smart-pointers/
the use of any pointers is to consider ownership+memory-management+lifetime.
Who was the owner of this object? Is there one owner or many? Who would responese for the deletion?
Using unique_ptr means that the object is owner but can be transferred (Std::move)
Plain pointers should never be used to act as the ' owners ' of objects
Use shared_ptr as much as possible, consider weak_ptr in ring references (does not increase the reference count of only needles)
Assign a value to shared_ptr or unique_ptr immediately after an object is created, and immediately assign a normal pointer to a smart pointer when the function returns a normal pointer to ensure automatic memory management
A smart pointer object is stored directly in container as a value, not as a pointer or reference, passing a function argument as a value, returning a function with a value (Std::move, rvalue Reference).
Using shared_ptr is multithreaded security, but shared_ptr itself is not multithreaded security. That is, when using smart pointers in multi-threading, each thread should have a shared_ptr object instead of multiple threads using the same shared_ptr object.
move:https://mbevin.wordpress.com/2012/11/20/move-semantics/
move and STD template container application:
To be continued ...
C++11 shared_ptr & unique_ptr & Move semantics (rvalue reference)