From: Phil Nash (phil.nash.lists_at_[hidden])
Date: 2006-04-10 05:49:46
Maxim Yegorushkin wrote:
> On 4/10/06, Bronek Kozicki <brok_at_[hidden]> wrote:
>> Maxim Yegorushkin <maxim.yegorushkin_at_[hidden]> wrote:
>>> All developers I know roll out their own versions of lexical_cast.
>>> Last time I checked the implementation of boost::lexical_cast it had
>>> efficiency bugs. There at least should be specializations for string
>>> -> integer/double conversions that use strtoul/d functions directly
>>> rather than iostreams.
>> the other problem that I have with lexical_cast is that currently it's
>> impossible to tell whether particular conversion will fail without
>> actually catching exception (which implies huge performance penalty).
>> This is needed in all situations where "invalid" input is not an error
>> (eg. optional data coming from external source)
> True. Boost have long ignored these issues, no wonder they accepted it
The thing is, lexical_cast in its current implementation, is simple and
elegant, and perfectly usable for most cases.
It doesn't preclude optimisations in the *implementation*, and some such
optimisations have been suggested. It would be nice to see some
actually implemented in the reference implementation.
As to the error handling - I haven't personally given it much thought -
but I'm not sure that can be easily parameterised without disturbing the