In hindsight, given make_shared, would shared_ptr have a constructor that takes a raw pointer had it been introduced with C++11?
make_shared
shared_ptr
Are there stro
std::shared_ptr does much more than allocate objects on the heap.
std::shared_ptr
Consider its use as an auto-closing shared file handle:
#include #include int main() { auto closer = [](FILE* fp) { std::fclose(fp); }; auto fp = std::shared_ptr(std::fopen("foo.txt", "r"), closer); }