Master/Slave smart-pointer
This is decidedly shady:

O&amp; operator*() const {
    if (m_ptr.expired())
        throw ObjectInvalid();

    return m_ptr.lock().operator*();
}

O* operator-&gt;() const {
    if (m_ptr.expired())
        throw ObjectInvalid();

    return m_ptr.lock().operator-&gt;();
}


In the line:

return m_ptr.lock().operator-&gt;();


You create a shared pointer. Get the pointer value from the shared pointer. Destroy the shared pointer then return the pointer that was in the shared pointer.

So now you have a pointer but no guarantee that the object it points at exists anymore (as you destroyed your copy of the shared pointer).

There are a couple of operations on the master pointer that you don't support.


You can't test if it is empty.
So you are playing Russian roulette every time you use it.
You can't use it as part of a conditional (ie no conversion to bool).
You don't have a constructor that takes a nullptr => std::nullptr_t
You have a couple of problems with implicit construction.