----- Original Message -----From: Björn KarlssonSent: Friday, January 25, 2002 12:58 PMSubject: RE: [boost] Proposal for lexical_cast/lexical_convert> From: Fernando Cacciola [mailto:fcacciola@gosierra.com]
>
> I think this would be really useful, but I would use a
> different signature:
>
> template<typename Target, typename Source>
> Target lexical_convert(Source arg, bool* succeeded = 0 ) ;
>
> This has some advantages:
>
> 1) You don't have to remember which parameter, first or second, is the
> source/target.
> 2) It looks closer to any other convertion function in that
> it returns the
> converted value.
> 3) You can use it ignoring the boolean flag in cases you
> don't care to test
> if it succeeded at all
> (that's why the boolean parameter is a pointer and not a
> reference)
>Alas, there's also a downside to this approach - the type of Target cannot be deduced.
True.
Anyway, most casts require explicit targeting, so I think that the advantages outweigh this limitation.
Fernando Cacciola
Sierra s.r.l.
fcacciola@gosierra.com
www.gosierra.com