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

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

Section: 31.7 [iostream.format] Status: NAD Submitter: Marc Steinbach Opened: 2009-06-20 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [iostream.format].

View all issues with NAD status.

Discussion:

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

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

The argument types should be streamsize, as in class ios_base (see 31.5.2 [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 31.7 [iostream.format], header <iomanip> synopsis change as indicated:

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

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

    unspecified setw(intstreamsize n);