Section: 31.5.2.3 [fmtflags.state] Status: NAD Submitter: Judy Ward Opened: 2000-12-30 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [fmtflags.state].
View all issues with NAD status.
Discussion:
The Effects clause for ios_base::setf(fmtflags fmtfl) says "Sets fmtfl in flags()". What happens if the user first calls ios_base::scientific and then calls ios_base::fixed or vice-versa? This is an issue for all of the conflicting flags, i.e. ios_base::left and ios_base::right or ios_base::dec, ios_base::hex and ios_base::oct.
I see three possible solutions:
Most existing implementations that I tried seem to conform to resolution #3, except that when using the iomanip manipulator hex or oct then that always overrides dec, but calling setf(ios_base::hex) doesn't.
There is a sort of related issue, which is that although the ios_base constructor says that each ios_base member has an indeterminate value after construction, all the existing implementations I tried explicitly set ios_base::dec.
Proposed resolution:
Rationale:
adjustfield
, basefield
, and floatfield
are each multi-bit fields. It is possible to set multiple bits within
each of those fields. (For example, dec
and
oct
). These fields are used by locale facets. The LWG
reviewed the way in which each of those three fields is used, and
believes that in each case the behavior is well defined for any
possible combination of bits. See for example Table 58, in 28.3.4.3.3.3 [facet.num.put.virtuals], noting the requirement in paragraph 6 of that
section.
Users are advised to use manipulators, or else use the two-argument
version of setf
, to avoid unexpected behavior.