Hi, On Sunday 29 December 2002 01:29, Terje Slettebų wrote: > > there...) Anyway, the surprising result of this was that the space in > > "Hello there" caused the interpreter.eof() check in lexical_cast to fail. > > So if that check were not present, dest would have been assigned the > > value "Hello". Fortunately, the check was there, and instead I got a > > bad_lexical_cast exception. > > This issue comes up at regular intervals, since this is one of the known > problems of lexical_cast, but it hasn't yet been fixed. See e.g. this > posting (http://aspn.activestate.com/ASPN/Mail/Message/1454894). > > A proposition has been made to fix this and other things > (http://groups.yahoo.com/group/boost/files/lexical_cast_proposition/), and > I'll get to update it properly, and write the docs for it, soon. It should > work correctly as it is, as it's been tested in an extensive unit test > (also found at the same place). > > > Is this the way lexical_cast is intended to work? > > No, Kevlin has acknowledged that this is a known problem with the current > version of lexical_cast, the handling of whitespace in strings and > characters.
I am still uncertain whether this is a problem with lexical_cast and whether it should be fixed. The stated purpose of lexical_cast is type conversion through string representation. I think this is a simple but powerful concept. To me the actual problem is not in lexical_cast but in the std::basic_strings stream operator semantics. Basically you cannot read strings containing whitespace as a whole. I.e. the integrity of a string containing whitespace is lost once you streamed it. This is a fundamental if at times undesirable property of std::basic_string and char const* for that matter. I don't know whether it is a good idea for lexical_cast to try to fix it. Just my 2c Thomas -- Dipl.-Ing. Thomas Witt Institut fuer Verkehrswesen, Eisenbahnbau und -betrieb, Universitaet Hannover voice: +49(0) 511 762 - 4273, fax: +49(0) 511 762-3001 http://www.ive.uni-hannover.de _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost