Although it is possible to implement optimized allocation schemes using class-specific new and delete operators, smart pointers give you the freedom to choose whether to use the optimized scheme for each object, instead of having the scheme set for all objects of a class. It is therefore possible to match the allocation scheme to different operating environments and applications, without modifying the code for the entire class. To achieve these two design goals, STL containers store their objects by value. This means that if you have an STL container that stores objects of class Base, it cannot store of objects of classes derived from Base. This is both error prone and not exception safe.
Smart pointers are a possible solution, as illustrated below.
Therefore, all copies of an element must be equivalent, or the wrong copy may be the one to survive all this copying and deleting. Well, this summary should help. If there are no special requirements, you should use it. For local variables, it is usually the right choice. It is important to consider the characteristics of the specific garbage collection scheme used.