diff --git a/lexical_cast.htm b/lexical_cast.htm
index f55d741..2a08541 100644
--- a/lexical_cast.htm
+++ b/lexical_cast.htm
@@ -20,6 +20,10 @@
lexical_cast
bad_lexical_cast
Q: Why does lexical_cast<int8_t>("127")
throw bad_lexical_cast
?
+
A: The type int8_t
is a typedef to char
or signed char
.
+ 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:
+
+
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:
+
+
lexical_cast<std::string>(static_cast<int>(n));+ +
Q: The implementation always resets the ios_base::skipws
flag of an underlying stream object. It breaks my operator>>
that works only in presence of this flag. Can you remove code that resets the flag?
+
A: May be in a future version. There is no requirement in [N1973] to reset the flag but remember that [N1973] is not yet accepted by the committee. By the way, it's a great opportunity to make your operator>>
conform to the standard. Read a good C++ book, study std::sentry
and ios_state_saver.
+
+
Source
and Target
+ types. Refer to [Tuning] for more details.
+