Top "Shared-ptr" questions

Reference counted smart pointer class implementing shared ownership

Using smart pointers for class members

I'm having trouble understanding the usage of smart pointers as class members in C++11. I have read a lot about …

c++ c++11 shared-ptr smart-pointers unique-ptr
Check for null in std::shared_ptr

I was wondering if i need to check whether sp is null before i use it. Correct me if I …

c++ shared-ptr
getting a normal ptr from shared_ptr?

I have something like shared_ptr<Type> t(makeSomething(), mem_fun(&Type::deleteMe)) I now need to …

c++ boost smart-pointers shared-ptr
std::shared_ptr initialization: make_shared<Foo>() vs shared_ptr<T>(new Foo)

What's the difference between: std::shared_ptr<int> p = std::shared_ptr<int>( new int ); and …

c++ c++11 shared-ptr smart-pointers
Explicitly deleting a shared_ptr

Simple question here: are you allowed to explicitly delete a boost::shared_ptr yourself? Should you ever? Clarifying, I don't …

c++ boost shared-ptr boost-smart-ptr
C++11 When clearing shared_ptr, should I use reset or set to nullptr?

I have a question about C++11 best practices. When clearing a shared_ptr, should I use the reset() function with …

c++ c++11 shared-ptr reset nullptr
How do I call ::std::make_shared on a class with only protected or private constructors?

I have this code that doesn't work, but I think the intent is clear: testmakeshared.cpp #include <memory> …

c++ c++11 shared-ptr
Difference between `const shared_ptr<T>` and `shared_ptr<const T>`?

I'm writing an accessor method for a shared pointer in C++ that goes something like this: class Foo { public: return_…

c++ boost constants shared-ptr
std::shared_ptr thread safety explained

I'm reading http://gcc.gnu.org/onlinedocs/libstdc++/manual/shared_ptr.html and some thread safety issues are still not …

c++ c++11 shared-ptr
Does C++11 unique_ptr and shared_ptr able to convert to each other's type?

Does C++11 standard library provide any utility to convert from a std::shared_ptr to std::unique_ptr, or vice …

c++ c++11 shared-ptr unique-ptr