|
Boost : |
From: Alexander Nasonov (alnsn_at_[hidden])
Date: 2007-05-15 17:36:00
I'm going to commit to HEAD two new sections 'Frequently Asked
Questions' and 'References' and also update 'Changes' section.
Any objections, corrections etc?
New documentation is here http://194.6.223.221/~nasonov/lexical_cast.htm
Frequently Asked Questions
Q: Why lexical_cast<int8_t>("127") throws 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 check
is important, you can also call numeric_cast:
numeric_cast<int8_t>(lexical_cast<int>("127"));
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. The is no requirement in [N1973] to
reset the flag but remember that [N1973] is not yet accepted by
the commitee. By the way, it's a greate opportunity to make your
operator>> conform to the standard. Read a good C++ book, study
std::sentry and ios_state_saver.
References
* [N1973] Kevlin Henney, Beman Dawes, Lexical Conversion Library
* Proposal for TR2, N1973.
* [Tuning] Alexander Nasonov, Fine Tuning for lexical_cast,
* Overload #74, August 2006.
Changes
August, October 2006:
* Better performance for many combinations of Source and Target
* types. Refer to [Tuning] for more details.
-- Alexander Nasonov http://nasonov.blogspot.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk