Top "Smart-pointers" questions

An abstract data type that simulates a pointer while providing additional features, such as automatic garbage collection or bounds checking

Example to use shared_ptr?

Hi I asked a question today about How to insert different types of objects in the same vector array and …

c++ boost vector shared-ptr smart-pointers
Is there any use for unique_ptr with array?

std::unique_ptr has support for arrays, for instance: std::unique_ptr<int[]> p(new int[10]); but is …

c++ c++11 smart-pointers unique-ptr
Why can I not push_back a unique_ptr into a vector?

What is wrong with this program? #include <memory> #include <vector> int main() { std::vector<std::…

c++ stl c++11 smart-pointers unique-ptr
Where is shared_ptr?

I am so frustrated right now after several hours trying to find where shared_ptr is located. None of the …

c++ boost c++11 shared-ptr smart-pointers
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
smart pointers (boost) explained

What is the difference between the following set of pointers? When do you use each pointer in production code, if …

c++ boost smart-pointers
How to return smart pointers (shared_ptr), by reference or by value?

Let's say I have a class with a method that returns a shared_ptr. What are the possible benefits and …

c++ return smart-pointers
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