forked from boostorg/conversion
Remove a couple of bugs, clarify a couple of minor points; from Kevlin
[SVN r14148]
This commit is contained in:
@@ -79,8 +79,13 @@ convenience for such conversions. For more involved conversions, such as where
|
|||||||
precision or formatting need tighter control than is offered by the default
|
precision or formatting need tighter control than is offered by the default
|
||||||
behavior of <code>lexical_cast</code>, the conventional
|
behavior of <code>lexical_cast</code>, the conventional
|
||||||
<code>stringstream</code> approach is recommended. Where the conversions are
|
<code>stringstream</code> approach is recommended. Where the conversions are
|
||||||
numeric to numeric, <code><a href="cast.htm#numeric_cast">numeric_cast</a></code> may offer more reasonable
|
numeric to numeric, <code><a href="cast.htm#numeric_cast">numeric_cast</a></code>
|
||||||
behavior than <code>lexical_cast</code>.
|
may offer more reasonable behavior than <code>lexical_cast</code>.
|
||||||
|
<p>
|
||||||
|
For a good discussion of the options and issues involved in string-based formatting,
|
||||||
|
including comparison of <code>stringstream</code>, <code>lexical_cast</code>, and
|
||||||
|
others, see Herb Sutter's article, <a href="http://www.gotw.ca/publications/mill19.htm">
|
||||||
|
<i>The String Formatters of Manor Farm</i></a>.
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
@@ -154,12 +159,8 @@ template<typename Target, typename Source>
|
|||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
||||||
Returns the result of streaming <code>arg</code> into a <code>std::stringstream</code> and then
|
Returns the result of streaming <code>arg</code> into a <code>std::stringstream</code> and then
|
||||||
out as a <code>Target</code> object. The conversion is parameterized by the current
|
out as a <code>Target</code> object. If the conversion is unsuccessful, a
|
||||||
<a href="#lexical_context"><code>lexical_context</code></a>, if set. If the conversion is
|
<a href="#bad_lexical_cast"><code>bad_lexical_cast</code></a> exception is thrown.
|
||||||
unsuccessful, a <a href="#bad_lexical_cast"><code>bad_lexical_cast</code></a> exception is thrown
|
|
||||||
if the current <a href="#lexical_context"><code>lexical_context</code></a> is set for throwing or
|
|
||||||
if there is no current <a href="#lexical_context"><code>lexical_context</code></a> set, otherwise a
|
|
||||||
<code>Target()</code> is returned.
|
|
||||||
<p>
|
<p>
|
||||||
The requirements on the argument and result types are:
|
The requirements on the argument and result types are:
|
||||||
<ul>
|
<ul>
|
||||||
@@ -220,23 +221,32 @@ preference to the standard <code><sstream></code> header for out-of-the-bo
|
|||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
A mechanism for providing quality-of-service control is needed, e.g. formatting and exception
|
Improved string handling, correctly accommodating wide character strings, incompatible
|
||||||
behavior. In the name of simplicity (and release), the current version strips out an earlier
|
<code>basic_string</code> types, and empty strings.
|
||||||
experimental version.
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
Wide character and incompatible <code>std::basic_string</code> issues need to be catered for.
|
Optimize the use of a stream away for identity conversions.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
An <code>interpret_cast</code> that performs a <i>do-something-reasonable</i> conversion between
|
An <code>interpret_cast</code> that performs a <i>do-something-reasonable</i> conversion between
|
||||||
types. It would, for instance, select between <code>numeric_cast</code> and <code>lexical_cast</code>
|
types. It would, for instance, select between <code>numeric_cast</code> and <code>lexical_cast</code>
|
||||||
based on <code>std::numeric_limits<>::is_specialized</code>.
|
based on <code>std::numeric_limits<>::is_specialized</code>. This would be an interesting
|
||||||
|
project, but there are no concrete plans to pursue this at the moment.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
It is also worth mentioning future <i>non-directions</i>: anything that involves adding extra
|
||||||
|
arguments for a conversion operation is not being considered. A custom keyword cast, such as
|
||||||
|
<code>lexical_cast</code>, is intended to look like a built-in cast operator: built-in cast operators
|
||||||
|
take only a single operand. Where a higher degree of control is required over conversions, the
|
||||||
|
standard <code>stringstream</code> offers a more appropriate path. Where non-stream-based conversions
|
||||||
|
are required, <code>lexical_cast</code> is the wrong tool for the job, and so it won't be special-cased
|
||||||
|
for such scenarios.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<div align="right"><small><i>© Copyright Kevlin Henney, 2000</i></small></div>
|
<div align="right"><small><i>© Copyright Kevlin Henney, 2000, 2002</i></small></div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Reference in New Issue
Block a user