Movatterモバイル変換


[0]ホーム

URL:



This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofCD1 status.

118.basic_istream uses nonexistentnum_get member functions

Section: 31.7.5.3.2[istream.formatted.arithmetic]Status:CD1Submitter: Matt AusternOpened: 1998-11-20Last modified: 2016-01-28

Priority:Not Prioritized

View all otherissues in [istream.formatted.arithmetic].

View all issues withCD1 status.

Discussion:

Formatted input is defined for the typesshort,unsigned short,int,unsigned int,long,unsigned long,float,double,long double,bool, andvoid*. According to section 27.6.1.2.2,formatted input of a valuex 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 typesbool,long,unsigned short,unsignedint,unsigned long,unsigned long,float,double,long double, andvoid*. Comparing the lists from the two sections, we findthat 27.6.1.2.2 is using a nonexistent function for typesshort andint.

Proposed resolution:

In 31.7.5.3.2[istream.formatted.arithmetic] Arithmetic Extractors, remove thetwo 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.]


[8]ページ先頭

©2009-2026 Movatter.jp