<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3271: Parsing functions should save and restore stream format state</title>
<meta property="og:title" content="Issue 3271: Parsing functions should save and restore stream format state">
<meta property="og:description" content="C++ library issue. Status: NAD">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3271.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#NAD">NAD</a> status.</em></p>
<h3 id="3271"><a href="lwg-closed.html#3271">3271</a>. Parsing functions should save and restore stream format state</h3>
<p><b>Section:</b> 30.13 <a href="https://wg21.link/time.parse">[time.parse]</a> <b>Status:</b> <a href="lwg-active.html#NAD">NAD</a>
 <b>Submitter:</b> Howard Hinnant <b>Opened:</b> 2019-09-02 <b>Last modified:</b> 2020-09-06</p>
<p><b>Priority: </b>3
</p>
<p><b>View other</b> <a href="lwg-index-open.html#time.parse">active issues</a> in [time.parse].</p>
<p><b>View all other</b> <a href="lwg-index.html#time.parse">issues</a> in [time.parse].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#NAD">NAD</a> status.</p>
<p><b>Discussion:</b></p>
<p>
<code>from_stream</code> overloads may need to set various formatting state and flags of the <code>basic_istream</code> 
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 <code>basic_istream</code> they may need to change.
</p>

<p><i>[2019-10 Priority set to 3 after reflector discussion]</i></p>


<p><i>[2020-02, Prague; Close as NAD]</i></p>


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.


<p id="res-3271"><b>Proposed resolution:</b></p>
<p>This wording is relative to <a href="https://wg21.link/n4830">N4830</a>.</p>

<blockquote class="note">
<p>
[<i>Drafting note:</i> The modification of 30.13 <a href="https://wg21.link/time.parse">[time.parse]</a> p1 is intended to be non-conflictingly 
mergeable with the change suggested by LWG <a href="lwg-defects.html#3269" title="Parse manipulators do not specify the result of the extraction from stream (Status: C++20)">3269</a><sup><a href="https://cplusplus.github.io/LWG/issue3269" title="Latest snapshot">(i)</a></sup> at the same paragraph.]
</p>
</blockquote>

<ol>
<li><p>Modify 30.13 <a href="https://wg21.link/time.parse">[time.parse]</a> as indicated:</p>

<blockquote>
<p> 
-1- Each parse overload specified in this subclause calls <code>from_stream</code> unqualified, 
so as to enable argument dependent lookup (6.5.4 <a href="https://wg21.link/basic.lookup.argdep">[basic.lookup.argdep]</a>).
<ins>In the following paragraphs, let <code>is</code> denote an object of type 
<code>basic_istream&lt;charT, traits&gt;</code>, where <code>charT</code> and
<code>traits</code> are template parameters in that context.</ins>
<p/>
[&hellip;]
<p/>
-10- All <code>from_stream</code> overloads behave as unformatted input functions, except that they have an 
unspecified effect on the value returned by subsequent calls to <code>basic_istream&lt;&gt;::gcount()</code>.
<ins>Any changes made to <code>is.fill()</code>, <code>is.width()</code> or <code>is.flags()</code> are undone 
prior to an returning or exceptional execution ([thread.once.callonce]).</ins> 
Each overload takes a format string containing ordinary characters and flags which have special meaning. 
Each flag begins with a <code>%</code>. Some flags can be modified by <code>E</code> or <code>O</code>. 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 
<code><i>N</i></code> 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.
</p>
</blockquote>

</li>
</ol>





</body>
</html>
