Topic: Defect Report [N2134]: New 27.6.1.2.2 changes make special extractions useless
Author: "=?iso-8859-1?q?Daniel_Kr=FCgler?=" <daniel.kruegler@googlemail.com>
Date: Sun, 1 Apr 2007 14:41:39 CST Raw View
To the more drastic changes of 27.6.1.2.2-
[istream.formatted.arithmetic]
in the current draft N2134 belong the explicit description of the
extraction
of the types short and int in terms of as-if code fragments.
1) The corresponding as-if extractions in paragraph 2 and 3 will
never
result in a change of the operator>> argument val, because the
contents
of the local variable lval is in no case written into val. Furtheron
both
fragments need a currently missing parentheses in the beginning of
the
if-statement to be valid C++.
2) I would like to ask whether the omission of a similar explicit
extraction
of unsigned short and unsigned int in terms of long - compared to
their
corresponding new insertions, as described in 27.6.2.5.2, is a
deliberate
decision or an oversight.
Proposed resolution:
1) In 27.6.1.2.2/2 change the current as-if code fragment
typedef num_get<charT,istreambuf_iterator<charT,traits> > numget;
iostate err = 0;
long lval;
use_facet<numget>(loc).get(*this, 0, *this, err, lval );
if (err == 0)
&& (lval < numeric_limits<short>::min()
|| numeric_limits<short>::max() < lval))
err = ios_base::failbit;
setstate(err);
to
typedef num_get<charT,istreambuf_iterator<charT,traits> > numget;
iostate err = 0;
long lval;
use_facet<numget>(loc).get(*this, 0, *this, err, lval );
if (err == 0) {
if (lval < numeric_limits<short>::min() ||
numeric_limits<short>::max() < lval)
err = ios_base::failbit;
else
val = static_cast<short>(lval);
}
setstate(err);
Similarily in 27.6.1.2.2/3 change the current as-if fragment
typedef num_get<charT,istreambuf_iterator<charT,traits> > numget;
iostate err = 0;
long lval;
use_facet<numget>(loc).get(*this, 0, *this, err, lval );
if (err == 0)
&& (lval < numeric_limits<int>::min()
|| numeric_limits<int>::max() < lval))
err = ios_base::failbit;
setstate(err);
to
typedef num_get<charT,istreambuf_iterator<charT,traits> > numget;
iostate err = 0;
long lval;
use_facet<numget>(loc).get(*this, 0, *this, err, lval );
if (err == 0) {
if (lval < numeric_limits<int>::min() || numeric_limits<int>::max()
< lval)
err = ios_base::failbit;
else
val = static_cast<int>(lval);
}
setstate(err);
2) ---
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]