Boost logo

Boost :

From: Moore, Paul (Paul.Moore_at_[hidden])
Date: 1999-11-05 09:57:25


From: Gavin Collings [mailto:gcollings_at_[hidden]]

> Darin's post indicates a meaning of purely documenting the
> fact that a compiler generated implicit type conversion is
> taking place. I don't think that is the intended use of
> implicit_cast.

No, he's suggesting that it can be used to force an implicit-type cast where
one would not otherwise occur His example was (IIRC) template argument
deductionbut a better example may be using implicit_cast<> to direct
overloading resolution - consider the case of
    cout << implicit_cast<int>('a');

> He suggests leaving warnings on, effectively reducing
> implicit_cast to nought, stating that if you want numeric
> conversions, you should use numeric_cast.

He has an example in his original post of how the cast could still be useful
without requiring a numeric check. My example above is another.

> But this misses the important case where the
> programmer knows from context that range checking is
> unnecessary, and wants to avoid the overhead.

You are probably right here, that there is a further case. But it isn't the
case that Darin is discussing.

My view is that having too many flavours of cast can be as bad (confusion
potential) as having too few. We're teetering on the edge, here.

Paul.


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