Boost logo

Boost Users :

From: Terje Slettebų (tslettebo_at_[hidden])
Date: 2005-01-29 17:06:47

>From: "Yuval Ronen" <ronen_yuval_at_[hidden]>


> I'm probably just another one out of a million who make these remarks,
> but I found nothing in the documentation about them, so I'll mention
> them anyway.

Very good. :) Actually, the second issue hasn't to my knowledge been brought
up, before, and while the first one has, it's a good question that deserves

I've brought this thread to Kevlin Henney's attention, as I've tended to
take care of lexical_cast related questions on the list (including
forwarding things needing his consideration, such as any changes to
lexical_cast, to him). I'm replying here to let you know that your report is
being taken care of.

> 1. lexical_cast(Source arg) takes the source argument by value. Why not
> by const& ? Calling lexical_cast(some_basic_string) now makes a copy of
> the source argument for no reason.

I heard from Kevlin that the reason was that there originally were some
issues with binding to string literals. Changing it to use const reference
in my local copy still gives a lot of error messages, having to do with
std::numeric_limits being used in the implementation. If we find a way to
fix this (yet letting it still work on compilers with no class template
partial specialisation, like MSVC 6), without breaking existing programs,
then apparently, this change should be ok. If anyone makes a patch for this,
it would be welcome.

> 2. lexical_cast ignores trailing whitespaces, but not leading
> whitespaces. Meaning that
> int a = lexical_cast<int>("3 "); // three-space
> will work and return 3, but
> int a = lexical_cast<int>(" 3"); // space-three
> will throw. Why? There's no rationale here. Both cases should be treated
> in the same manner, and IMHO, that manner should be throwing.

In Kevlin's reply to me, he agreed with this. This has been fixed, and will
likely be committed soon, and a note posted about the update.

Thanks for your feedback, and sorry for the late response.



Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at