Top "Smart-pointers" questions

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

intrusive_ptr in c++11

Does C++11 have something equivalent to boost::intrusive_ptr? My problem is that I have a C-style interface over my …

c++ c++11 boost shared-ptr smart-pointers
How do I pass smart pointers into functions?

When passing objects into functions, do the same rules apply to smart pointers as to other objects that contain dynamic …

c++ c++11 parameter-passing smart-pointers unique-ptr
Smart pointers in container like std::vector?

I am learning about smart pointers (std::auto_ptr) and just read here and here that smart pointers (std::auto_…

c++ pointers std smart-pointers auto-ptr
C++ using scoped_ptr as a member variable

Just wanted opinions on a design question. If you have a C++ class than owns other objects, would you use …

c++ oop smart-pointers
How to enable_shared_from_this of both parent and derived

I have simple base and derived class that I want both have shared_from_this(). This simple solution: class foo : …

c++ boost smart-pointers
How to avoid memory leak with shared_ptr?

Consider the following code. using boost::shared_ptr; struct B; struct A{ ~A() { std::cout << "~A" << …

c++ boost memory-leaks shared-ptr smart-pointers
C++11: Replace all non-owning raw pointers with std::shared_ptr()?

With the advent of std::unique_ptr, the blemished std::auto_ptr can finally be put to rest. So for …

c++ memory c++11 smart-pointers
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
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
C++0x unique_ptr replaces scoped_ptr taking ownership?

I used to write code like this: class P {}; class Q: public P {}; class A { // takes ownership A(P* p): …

c++ smart-pointers c++11