This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.
basic_istream
uses nonexistent num_get
member functionsSection: 31.7.5.3.2 [istream.formatted.arithmetic] Status: CD1 Submitter: Matt Austern Opened: 1998-11-20 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [istream.formatted.arithmetic].
View all issues with CD1 status.
Discussion:
Formatted input is defined for the types short
, unsigned short
, int
,
unsigned int
, long
, unsigned long
, float
, double
,
long double
, bool
, and void*
. According to section 27.6.1.2.2,
formatted input of a value x
is done as if by the following code fragment:
typedef num_get< charT,istreambuf_iterator<charT,traits> > numget; iostate err = 0; use_facet< numget >(loc).get(*this, 0, *this, err, val); setstate(err);
According to section 28.3.4.3.2.2 [facet.num.get.members], however,
num_get<>::get()
is only overloaded for the types
bool
, long
, unsigned short
, unsigned
int
, unsigned long
, unsigned long
,
float
, double
, long double
, and
void*
. Comparing the lists from the two sections, we find
that 27.6.1.2.2 is using a nonexistent function for types
short
and int
.
Proposed resolution:
In 31.7.5.3.2 [istream.formatted.arithmetic] Arithmetic Extractors, remove the two lines (1st and 3rd) which read:
operator>>(short& val); ... operator>>(int& val);
And add the following at the end of that section (27.6.1.2.2) :
operator>>(short& val);The conversion occurs as if performed by the following code fragment (using the same notation as for the preceding 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);operator>>(int& val);The conversion occurs as if performed by the following code fragment (using the same notation as for the preceding 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<int>::min() || numeric_limits<int>::max() < lval)) err = ios_base::failbit; setstate(err);
[Post-Tokyo: PJP provided the above wording.]