From en.cppreference.com
Typical uses of std::unique_ptr include:
providing exception safety to classes and functions that handle objects with dynamic lifetime, by guaranteeing deletion on both normal exit and exit through exception
passing ownership of uniquely-owned objects with dynamic lifetime into functions
acquiring ownership of uniquely-owned objects with dynamic lifetime from functions
as the element type in move-aware containers, such as std::vector, which hold pointers to dynamically-allocated objects (e.g. if polymorphic behavior is desired)
I am interested in the first point.
It is not mentioned for shared_ptr
in cppreference.com.
I am not able to find a scenario where the shared_ptr doesn't get deleted when an exception is thrown. Could someone please explain if there exists such possibilities ?