Top "Shared-ptr" questions

Reference counted smart pointer class implementing shared ownership

Why is shared_ptr<void> legal, while unique_ptr<void> is ill-formed?

The question really fits in the title: I am curious to know what is the technical reason for this difference, …

c++ shared-ptr smart-pointers unique-ptr
Equality-compare std::weak_ptr

I want to compare two std::weak_ptr's or one std::weak_ptr and one std::shared_ptr for equality. …

c++ c++11 shared-ptr weak-ptr
std::shared_ptr deep copy object

Can't find much on that for C++11 but only on boost. Consider the following class: class State { std::shared_ptr&…

c++11 shared-ptr deep-copy
What are potential dangers when using boost::shared_ptr?

What are some ways you can shoot yourself in the foot when using boost::shared_ptr? In other words, what …

c++ boost pointers shared-ptr
Should I std::move a shared_ptr in a move constructor?

Consider: #include <cstdlib> #include <memory> #include <string> #include <vector> #include <algorithm&…

c++ c++11 shared-ptr rvalue-reference
How do shared pointers work?

How do shared pointers know how many pointers point to that object? (shared_ptr, in this case)

c++ c++11 shared-ptr
Why is the size of make_shared two pointers?

As illustrated in the code here, the size of the object returned from make_shared is two pointers. However, why …

c++ c++11 shared-ptr
How to access target of std::tr1::shared_ptr in GDB

How can I access target of a std::tr1::shared_ptr in GDB. This doesn't work: (gdb) p sharedPtr->…

c++ gdb shared-ptr tr1
What (not) to do in a constructor

I want to ask you for your best practices regarding constructors in C++. I am not quite sure what I …

c++ oop constructor shared-ptr
Initializing shared_ptr member variable, new vs make_shared?

When initializing a shared_ptr member variable: // .h class Customer { public: Customer(); private: std::shared_ptr<OtherClass> something_; } // .…

c++ c++11 shared-ptr initializer make-shared