How do smart pointers prevent memory leaks in C++11/14, and what are the performance trade-offs of using std::shared_ptr?