
On 4/10/06, Phil Nash <phil.nash.lists@gmail.com> wrote:
Maxim Yegorushkin wrote:
On 4/10/06, Bronek Kozicki <brok@rubikon.pl> 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.
Maxim Yegorushkin <maxim.yegorushkin@gmail.com> wrote: 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 tentatively.
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 interface.
So have a try_lexical_cast which takes a reference to the output var and returns a bool of success, and have lexical_cast wrap it to throw an exception on failure.
Best regards,
[)o IhIL.. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- Cory Nelson http://www.int64.org