|
Boost : |
From: Brian McNamara (lorgon_at_[hidden])
Date: 2003-08-31 14:43:55
On Sun, Aug 31, 2003 at 11:11:10AM -0700, Mat Marcus wrote:
> --On Sunday, August 31, 2003 1:35 PM -0400 Brian McNamara
> >On Sun, Aug 31, 2003 at 11:59:42PM +0800, Joel de Guzman wrote:
> >>It's really strange (and hard to explain) that you have to
> >>dereference optional<B>. Example:
> >>
> >> F(tuple<A, optional<B>, C> args)
> >> {
> >> A a = get<1>(args);
> >> B b = *get<2>(args); // strange!
> >> C c = get<3>(args);
> >> }
> >
> >I don't think it's strange at all; an optional<B> is not a B!
>
> That doesn't make it a pointer to B!
True. See my message of a moment ago, where I adopt the notion that
'*' is just an unfortunate coincidence of names, and that any
relationship between optional and pointers is mere happenstance. (This
all despite the documentation on optional which explicitly describes
the relationship; I am merely trying to present another way of looking
at it which may be useful.)
> >As another example, FC++ lists support conversion-to-bool
>
> There's conversion-to-bool again. I still wonder whether dispensing
> with this would open the door to implicit conversions.
I think no.
I should mention in passing that, while in general I think "implicit
conversions" are bad news and should be avoided whenever reasonable, I
do think the "conversion to bool" is an exceptional case, simply because
it is already so deeply ingrained in C++ (and C) language/culture.
(Fortunately bool has a very narrow interface, so it doesn't get us into
too much trouble. Implicit conversions to user-defined types may create
arbitrary interface conflicts/conceptual ambiguities, and this is where
the real trouble begins.)
-- -Brian McNamara (lorgon_at_[hidden])
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk