For 1, I'm not sure.
For 2, It seems more like a problem with stringstream - I think
lexical_cast does:
stringstream ss;
ss << input;
ss >> output;
return output;
On Sat, 15 Jan 2005 18:47:57 +0200, Yuval Ronen
Hi. 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.
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.
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. After a look at the code, it seems that the trailing-whitespace-ignore code ('stream >> std::ws' in line 151) was specifically added, so there was supposed to be a reason for this. But as I said, I believe this is wrong, at least as the default behaviour when converting a string to something else. Maybe some policies (IgnoreLeadingWhitespace, IgnoreTrailingWhitespace) can be added to control this? And again, I suppose I'm not the first to think of it...
Thanks, Yuval
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Cory Nelson http://www.int64.org