Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2002-10-02 13:11:21


"Peter Dimov" <pdimov_at_[hidden]> wrote in message
news:005501c26a0c$3744c200$1d00a8c0_at_pdimov2...
> [...]
> typedef foo * foo_ptr;
>
> > void g(foo_ptr const& p)
> > {
> > p->bar();
> > p->baz(3); // No Error!
>
> Ditto.
>
> > }

True, but people generally don't pass T* const&, and are generally happy
to pass around T* and specify T const* in a function call. Whereas,
smart pointer types tend to be verbose, and I, for one, always typedef
them. I guess the solution is to create a ptr<T const> typedef as well,
and use that in functions. You pay a copy for const-correctness, but I
guess that's just the way it is. Too bad there is no way to force a cast
that changes the type but does not introduce a copy, like builtin pointers.

Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk