From 3fb54557d29562dab14fd43f954a69f807a7150b Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Sun, 5 Oct 2008 01:47:33 +0000 Subject: [PATCH] merged from trunk [SVN r49133] --- lexical_cast.htm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lexical_cast.htm b/lexical_cast.htm index 6e38014..4bbdc8e 100644 --- a/lexical_cast.htm +++ b/lexical_cast.htm @@ -81,7 +81,7 @@ conversions, such as where precision or formatting need tighter control than is offered by the default behavior of lexical_cast, the conventional stringstream approach is recommended. Where the conversions are - numeric to numeric, numeric_cast + numeric to numeric, numeric_cast may offer more reasonable behavior than lexical_cast.

For a good discussion of the options and issues involved in string-based @@ -213,9 +213,9 @@ Eliminate an overhead of std::locale if your program runs in the "C Lexical conversion to these types is simply reading a byte from source but since the source has more than one byte, the exception is thrown.

Please use other integer types such as int or short int. If bounds checking - is important, you can also call numeric_cast: + is important, you can also call numeric_cast: -

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

Q: What does lexical_cast<std::string> of an int8_t or uint8_t not do what I expect?
A: As above, note that int8_t and uint8_t are actually chars and are formatted as such. To avoid this, cast to an integer type first: