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.

### 3271. Parsing functions should save and restore stream format state

Section: 27.13 [time.parse] Status: NAD Submitter: Howard Hinnant Opened: 2019-09-02 Last modified: 2020-09-06

Priority: 3

View all other issues in [time.parse].

View all issues with NAD status.

Discussion:

`from_stream` overloads may need to set various formatting state and flags of the `basic_istream` to implement the parsing functionality. Such settings must not persist beyond the parsing functions. Thus these functions need to save and restore any settings on the `basic_istream` they may need to change.

[2019-10 Priority set to 3 after reflector discussion]

[2020-02, Prague; Close as NAD]

LWG reviewed the issue and decided no change is needed. Unless specified to change the flags, it's assumed that the stream flags are unchanged by any input function.

Proposed resolution:

This wording is relative to N4830.

> [Drafting note: The modification of 27.13 [time.parse] p1 is intended to be non-conflictingly mergeable with the change suggested by LWG 3269 at the same paragraph.]

1. Modify 27.13 [time.parse] as indicated:

   > -1- Each parse overload specified in this subclause calls `from_stream` unqualified, so as to enable argument dependent lookup (6.5.4 [basic.lookup.argdep]). In the following paragraphs, let `is` denote an object of type `basic_istream<charT, traits>`, where `charT` and `traits` are template parameters in that context.

   > […]

   > -10- All `from_stream` overloads behave as unformatted input functions, except that they have an unspecified effect on the value returned by subsequent calls to `basic_istream<>::gcount()`. Any changes made to `is.fill()`, `is.width()` or `is.flags()` are undone prior to an returning or exceptional execution ([thread.once.callonce]). Each overload takes a format string containing ordinary characters and flags which have special meaning. Each flag begins with a `%`. Some flags can be modified by `E` or `O`. During parsing each flag interprets characters as parts of date and time types according to Table [tab:time.parse.spec]. Some flags can be modified by a width parameter given as a positive decimal integer called out as `N` below which governs how many characters are parsed from the stream in interpreting the flag. All characters in the format string that are not represented in Table [tab:time.parse.spec], except for white space, are parsed unchanged from the stream. A white space character matches zero or more white space characters in the input stream.