Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-10-09 01:14:59

"Maximilian Wilson" <wilson.max_at_[hidden]> 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.


> 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.


Boost list run by bdawes at, gregod at, cpdaniel at, john at