
"Maximilian Wilson" <wilson.max@gmail.com> wrote in message:
Actually, reference isn't all that different from a pointer except that you can use the dot operator (and operator <<, +, -, ==, etc.) on it without dereferencing first. I think you're looking for "smart references," but C++ doesn't really do them because you can't overload the dot operator.
Right.
I bet you could get something very close to what you want by defining another class smart_object<T> that inherits from shared_ptr<T>, but suppresses the -> and = operators and has an implicit conversion to T&.
Implicit conversions aren't applied before member access, so you won't be able to use the dot operator.
I believe that shared_ptr throws an exception if you try to dereference it while it's empty.
No -- it just causes an assertion failure. Jonathan