Boost logo

Boost :

From: Alexander Nasonov (alnsn_at_[hidden])
Date: 2007-05-09 13:53:52


> "Gregory Dai" <gregory.dai_at_[hidden]> wrote:
> > Nope, it's tempting to do "nice" thing, but again let's leave it at
> > that (see above), and close the subject.

Jody Hagins wrote:
> Just because IOstreams does it that way, does not mean it is correct for
> lexical_cast<>... Simply leaving it at that, and closing the subject
> does not seem like a good idea either...

I'd like to remind that boost doesn't have a sole control on
lexical_cast anymore, see N1973
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1973.html

There is a good sentence in the document:

"We are not in a position to change I/O streams at this late stage, but
something like lexical_cast is not required to repeat those little
surprises."

Though, I completely agree with Gregory.

What do you folks think of this change in the documentation?

FAQ

Q: Why lexical_cast<int8_t>("127") throws bad_lexical_cast?
A: The type int8_t is a typedef to signed char which is read
from a stream that holds "127". The bad_lexical_cast is thrown
because the stream is not at EOF after reading. The standard
defines same semantics for all char types. Possible workaround

numeric_cast<int8_t>(lexical_cast<int>("127"))

or, more generic expression for any integer type T

numeric_cast<T>(lexical_cast< promote<T>::type >("127"))

-- 
Alexander Nasonov
http://nasonov.blogspot.com
Reason is experimental intelligence, conceived after the pattern
of science, and used in the creation of social arts; it has something
to do. It liberates man from the bondage of the past, due to ignorance
and accident hardened into custom. It projects a better future and
assists man in its realization. -- John Dewey --
This quote is generated by: 
	/usr/pkg/bin/curl -L http://tinyurl.com/veusy         \
	  | sed -e 's/^document\.write(.//' -e 's/.);$/ --/'  \
	        -e 's/<[^>]*>//g' -e 's/^More quotes from //' \
	  | fmt | tee ~/.signature-quote

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk