Using c++11 smart pointers avoiding memory leaks.