shared_ptr implementation
Implementing your own smart pointer is very hard please don't try.

If it is just to try and learn then fine you may learn something but after practicing go back to one that has been tested and is know to work.

20 seconds into looking Bug 1:

int main()
{
    auto_&lt;int&gt;   x;
    auto_&lt;int&gt;   y(x);
    auto_&lt;int&gt;   z(x);
}


Problem caused by this line:

auto_(const auto_&lt;T&gt; &amp;o)
   : pValue(o.pValue)
   , pPrev(&amp;o)
   , pNext(NULL)
{
    o.pNext = this;   // Here you are overwriting x.pNext when building z
}                     // It may or may not cause a bug but it was definitely
                      // not what you intended to do.


You now have

pNext List
[X] -&gt; [Z] -&gt; |    Y/Z point at nothing
       [Y] -&gt; |    X   points at Z

pPrev List
[Y] -&gt; [X] -&gt; |    Y/Z point at X
[Z] ----^          X   points at nothing.

                   One assumes you are trying to create a circular list!


Don't use hungarian notation

pValue


Do you really want to bind your object to always using pointers?
Just use logical names for the members try not to encode type information into the name of the member it already has that information in its type.

Style Tip

Don;t do this:

    const auto_&lt;T&gt; *const pPrev = this-&gt;pPrev, *const pNext = this-&gt;pNext;


It really hard to read. You are doing complex enough stuff try and make it easy to read

    auto_&lt;T&gt; const* const pPrev = this-&gt;pPrev
    auto_&lt;T&gt; const* const pNext = this-&gt;pNext;


Don't do pointless work

    this-&gt;pPrev = this-&gt;pNext = NULL;
    this-&gt;pValue = NULL;


This does nothing. This object is going to be destroyed. Therefore these variables do not exist after the destructor exists. So little point in playing with their values just before destruction.

Don't manually call the destructor

        this-&gt;~auto_();


Nobody expects people to do this. Its just confusing. Move the code in the destructor into another method and call that.

Broken link

If sombody inserts a NULL pointer into your smart pointer you are asking for trouble when they de-reference it.

auto_&lt;int&gt;  x(NULL); // valid constructor


This is going to blow up

operator   T&amp;() /*also const version*/ { return  *this-&gt;pValue; }


You either need to check the ptr on construction (to make sure it is never NULL) or if you allow NULL pointers then you need to check when the object is used.

Specialization

To avoid repeating yourself allow your code to be specialized by a second template parameter that understands how to reclaim the resources of different types. The default version just calls delete but this allows you to use specialize it for handles etc.

Circular lists are easier with no NULL pointers.

template&lt;typename T&gt;
struct Deleter
{
    void operator()(T* ptr) const { delete ptr;}
};

template&lt;typename T, typename D = Deleter&lt;T&gt; &gt;
class my_auto
{
    T *value;
    mutable const my_auto&lt;T&gt;* prev;
    mutable const my_auto&lt;T&gt;* next;

    public:
    // set up the chain to be circular pointing at just itself.
    // This way next/prev will never be NULL and we don't need to test
    my_auto()           : value(new T()),  prev(this), next(this) { }
    my_auto(T *value)   : value(value),    prev(this), next(this) { if (value == 0) throw int(1);}
    my_auto(const T &amp;v) : value(new T(v)), prev(this), next(this) { }

    // insertInto() will do that appropriate set up.
    // We are currently not in a chain and have no value to release.
    my_auto(const my_auto&lt;T&gt; &amp;o)
    {
        insertInto(o);
    }

    my_auto&lt;T&gt;&amp; operator=(const my_auto&lt;T&gt;&amp; other)
    {
        // Check for assignment to self
        if (this != &amp;other)
        {
            testAndDestroy();
            removeFromChain();
            insertInto(other);
        }
        return *this;
    }

    ~my_auto()
    {
        testAndDestroy();
        removeFromChain();
    }

    private:
        // If next == this then this is the only node in the chain
        // So we destroy the data portion.
        void testAndDestroy()
        {
            if (next == this)
            {
                D     deleter;
                deleter(value);
            }
        }
        // Unlink this node from the chain.
        // If we are the only link in the chain it still works
        // we just remain linked to ourselves.
        void removeFromChain()
        {
            // Remove this node from the chain
            prev-&gt;next  = next;
            next-&gt;prev  = prev;
        }
        // Insert into another chain.
        // Assumes that we are not part of another chain
        // and that our data has already been released as required.
        void insertInto(const my_auto&lt;T&gt;&amp; other)
        {
            value           = other.value;

            next            = other.next;
            other.next.prev = this;

            prev            = other;
            other.next      = this;
        }
};


If you want to use a non circular list (then you need to fix the constructor)

auto_(const auto_&lt;T&gt; &amp;o)
    : pValue(o.pValue)
    , pPrev(&amp;o)
    , pNext(o.pNext)                      // Fix this line
{
    if (o.pNext) { o.pNext.prev = this;}  // Add this line
    o.pNext = this;
}
// Your code assumes the node is always added to the end of the list
// You can not guarantee this. So you need to take account of being
// inserted into the middle.