Top "Smart-pointers" questions

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

How can I use covariant return types with smart pointers?

I have code like this: class RetInterface {...} class Ret1: public RetInterface {...} class AInterface { public: virtual boost::shared_ptr<RetInterface&…

c++ covariance smart-pointers
shared_ptr magic :)

Mr. Lidström and I had an argument :) Mr. Lidström's claim is that a construct shared_ptr<Base&…

c++ destructor smart-pointers
Is it possible to use a C++ smart pointers together with C's malloc?

Some of my code still uses malloc instead of new. The reason is because I am afraid to use new …

c++ malloc new-operator smart-pointers
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
What is the best smart pointer return type for a factory function?

With respect to smart pointers and new C++11/14 features, I am wondering what the best-practice return values and function parameter …

c++ c++11 smart-pointers const-correctness
C++ object-pool that provides items as smart-pointers that are returned to pool upon deletion

I'm having fun with c++-ideas, and got a little stuck with this problem. I would like a LIFO class …

c++ c++11 smart-pointers pool
Some questions about using CComPtr (when use Release()? Can I return CComPtr?, ...)

I writing add-on for Internet Explorer(BHO) and I'm using CComPtr smart pointers. I wonder: When should I use CComPtr.…

c++ com smart-pointers bho
What's the best signature for clone() in C++?

As Scott Myers wrote, you can take advantage of a relaxation in C++'s type-system to declare clone() to return …

c++ clone smart-pointers covariant-return-types
Why shouldn't you use references to smart pointers?

I recall reading somewhere that using references to smart pointers can cause memory corruption. Is this simply because of using …

c++ smart-pointers
Why can't a pointer be automatically converted into a unique_ptr when returning it?

Let me pose my question through an example. #include <memory> std::unique_ptr<int> get_it() { …

c++ pointers c++11 smart-pointers explicit