Top "Shared-ptr" questions

Reference counted smart pointer class implementing shared ownership

How to pass deleter to make_shared?

Since C++11, because of several reasons, developers tend to use smart pointer classes for dynamic lifetime objects. And with those …

c++ c++11 shared-ptr smart-pointers make-shared
Using googlemock EXPECT_CALL with shared_ptr?

I have a test that works fine with a raw pointer, but I'm having trouble getting it work with a …

c++ shared-ptr googlemock
Should I use shared_ptr or unique_ptr?

I have a question about std::unique_ptr and std::shared_ptr. I know there are loads of questions about …

c++ c++11 shared-ptr smart-pointers unique-ptr
Use of enable_shared_from_this with multiple inheritance

BI am using enable_shared_from_this in my code, and I am not sure if its usage is correct. …

c++ c++11 shared-ptr multiple-inheritance enable-shared-from-this
What is the difference between an empty and a null std::shared_ptr in C++?

The cplusplus.com shared_ptr page calls out a distinction between an empty std::shared_ptr and a null shared_…

c++ c++11 shared-ptr
Can you use a shared_ptr for RAII of C-style arrays?

I'm working on a section of code that has many possible failure points which cause it to exit the function …

c++ raii shared-ptr
shared_ptr with malloc and free

I have working in large application which contain c and cpp. The all files saved as cpp extension but the …

c++ boost shared-ptr scoped-ptr
QSharedPointer, how to pass them around, and do I need them?

Been trying to understand shared pointer for a few days now and it feels like I cant seem to get …

c++ qt pointers shared-ptr qsharedpointer
why i can't cast nullptr to weak_ptr<>

class MyClass { public: MyClass(std::weak_ptr<MyClass> parent){} } i want to do this: auto newInstance = std::make_…

c++ casting null shared-ptr weak-ptr
How do you make std::shared_ptr not call delete()

I have functions that take in std::shared_ptr as an argument so I am forced to use std::shared_…

c++ c++11 shared-ptr