Boost logo

Boost :

From: Fernando Cacciola (fernando_cacciola_at_[hidden])
Date: 2003-09-01 12:36:34

Brian McNamara <lorgon_at_[hidden]> wrote in message
> On Mon, Sep 01, 2003 at 09:03:17AM +0800, Joel de Guzman wrote:
> > Do it the ref, tuple and variant way: get(). But get(), as an
> > element-access interface, should return a reference, not a pointer, as
> > it does currently.
> Clearly I had not been paying enough attention earlier in the thread; I
> was oblivious to the fact that get() was returning a pointer and not a
> reference. I think get() (or operator*(), or however it ends up being
> spelled) should indeed return a reference.
operator*() does indeed return a reference, and I agree that operator get()
should too.

Anyway, there is a pragmetic advantage in having a function return a
pointer. It allow us to mix test+access with one call, as in:

if ( T* p = opt.get() )

but this functionality can be provided but a separate methods called
get_ptr() given the expected meaning of a method named get() for
something that is a value container.

Fernando Cacciola

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