Re: [boost] whitespace and user-defined types in lexical_cast

30.01.07, 21:03, John Salmon <john@thesalmons.org>:
The patch satisfies that test on my system (Linux, gcc-3.3.3). I was surprised that such a test was not already in the regression suite. Something like it obviously should be, so I added some very similar tests just to be sure. These are in the original patch:
Thanks. I'll add them.
Yes. There have been a few discussions over the years. There are two basic themes: 1 - somebody thinks that lexical_cast ought to work on a type whose operator>> isn't smart enough to handle a non-default skipws flag. The response is typically "your operator>> is broken", followed by more or less discussion about whether lexical_cast should accommodate "broken" operator>> anyway. We are repeating this theme. 2 - a desire for consistency between the handling of leading whitespace and trailing whitespace. I would suggest that the fact that questions of type 1 keep coming up is an indication that the current behavior is surprising and alternatives should be explored. If we can change it so that it is less surprising to "newbies" without breaking anything else and without introducing new complexity, I think we should. OK.
I would suggest that the answer to questions of type 2 is to observe that it's not trailing whitespace that causes the exception, it's trailing *anything*. As such, it should be clearly documented. In fact, the proposed text for the specification of lexical_cast in TR2 makes this very clear. I'll make sure it's documented in boost.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1973.html Thanks for reminding me of this text. I found few inconsistencies with the boost documentation. -- Alexander Nasonov
participants (1)
-
Alexander Nasonov