1148. Wrong argument type of I/O stream manipulators setprecision() and setw()

Section: 30.7 [iostream.format] Status: NAD Submitter: Marc Steinbach Opened: 2009-06-20 Last modified: 2016-02-10

Priority: Not Prioritized

View all other issues in [iostream.format].

View all issues with NAD status.

Discussion:

The header <iomanip> synopsis in 30.7 [iostream.format] specifies

T5 setprecision(int n);
T6 setw(int n);

The argument types should be streamsize, as in class ios_base (see 30.5.3 [ios.base]):

streamsize precision() const;
streamsize precision(streamsize prec);
streamsize width() const;
streamsize width(streamsize wide);

(Editorial: 'wide' should probably be renamed as 'width', or maybe just 'w'.)

[ 2009-07-29 Daniel clarified wording. ]

[ 2009 Santa Cruz: ]

No concensus for this change. There was some interest in doing the opposite fix: Change the streamsize in <ios> to int. But ultimately there was no concensus for that change either.

Proposed resolution:

  1. In 30.7 [iostream.format], header <iomanip> synopsis change as indicated:

    T5 setprecision(intstreamsize n);
    T6 setw(intstreamsize n);
    
  2. In 30.7.6 [std.manip], just before p. 6 change as indicated:

    unspecified setprecision(intstreamsize n);
    
  3. In 30.7.6 [std.manip], just before p. 7 change as indicated:

    unspecified setw(intstreamsize n);