z automatically destroyed. This happens for every โautomaticโ variable. Even for pointers like int* , float* , some_class* , etc. However, when the original pointers are destroyed, they do not automatically delete d. This is the behavior of smart pointers.
Because of this property, smart pointers should always be used to express ownership semantics. They also do not require special mention in the constructor / assignment operator copy / move, most of the time you do not even need to write them when using smart pointers, since they do everything that you need.
source share