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

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

Though, I completely agree with Gregory.

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


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


or, more generic expression for any integer type T

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

Alexander Nasonov
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         \
	  | 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, gregod at, cpdaniel at, john at