c++ - Why is it wrong to use std::auto_ptr<> with standard containers?

c++ - Why is it wrong to use std::auto_ptr<> with standard containers?

Why is it wrong to use std::auto_ptr<> with standard containers?…


c++ - Getting a boost::shared_ptr for this

I am making extensive use of boost:shared_ptr in my code. In fact, most of the objects that are allocated on the heap are held by a shared_ptr. Unfortunately this means that I can't pass this into any…


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 the reference of the smart pointer after its been destroyed? Or does…



c++ - 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> get_r() const=0;...}; class…


c++ dynamic_cast error handling

Is there any good practice related to dynamic_cast error handling(except not using it when you don't have to)? I'm wondering how should I go about NULL and bad_cast it can throw. Should I check for…


Is it wrong to use auto_ptr with new char

If I declare a temporary auto deleted character buffer using std::auto_ptr<char> buffer(new char[n]); then the buffer is automatically deleted when the buffer goes out of scope. I would assume that t…


Why shared_ptr has an explicit constructor

I was wondering why shared_ptr doesn't have an implicit constructor. The fact it doesn't is alluded to here: Getting a boost::shared_ptr for this(I figured out the reason but thought it would be a f…


std::auto_ptr or boost::shared_ptr for pImpl idiom?

When using the pImpl idiom is it preferable to use a boost:shared_ptr instead of a std::auto_ptr? I'm sure I once read that the boost version is more exception friendly? class Foo{public: Foo(…


C++-passing references to std::shared_ptr or boost::shared_ptr

If I have a function that needs to work with a shared_ptr, wouldn't it be more efficient to pass it a reference to it(so to avoid copying the shared_ptr object)? What are the possible bad side effect…


Reference Counting in C++

I'm implementing a math library in C++. The library will be compiled to a DLL so those who use it will only need the header files the classes' definitions. The users of my classes will be people who…




example pointer unique_ptr std smart implementation shared make_shared pointers nullptr