Boost logo

Boost :

From: Nicolas Fleury (nidoizo_at_[hidden])
Date: 2003-11-07 13:27:42


Andy Little wrote:
> If the facilities are there you can decide whether or not to use them.
> I see this as a policy thing. If it is your company policy not to convert
> there is nothing to stop you
> commenting out all the conversion functions in the headers :-)

Hi Andy,

I agree with Deane, I prefer a design forcing the conversion to be
explicit. Something like (or any other way of making the conversion
explicit):
TypeA x; TypeB y;
TypeA z = x + TypeA(y);

This is less error-prone. For similar reasons it is justified that
std::string doesn't provide an implicit conversion to const char*, it is
justified to force explicit conversion in that case. I agree with Deane
you're work/challenge is interesting, but still not a design I would
choose. I remember searching for a way to do:
template <typename X, typename Y>
Value<Result<X,Y>::Sum> operator+(Value<X> x, Value<Y> y);

to discover it was impossible without a typeof operator (or many
specializations). In the end, it was better and simpler to not do it
anyway and even with a typeof I would stuck with explicit conversion.

Regards,

Nicolas


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