<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Fri, 21 Feb 2025 at 10:09, Hans Åberg &lt;<a href="mailto:haberg_1@icloud.com">haberg_1@icloud.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
&gt; On 21 Feb 2025, at 10:53, Jonathan Wakely &lt;<a href="mailto:cxx@kayari.org" target="_blank">cxx@kayari.org</a>&gt; wrote:<br>
&gt; <br>
&gt; On Fri, 21 Feb 2025 at 09:08, Hans Åberg &lt;<a href="mailto:haberg_1@icloud.com" target="_blank">haberg_1@icloud.com</a>&gt; wrote:<br>
&gt; <br>
&gt; &gt; On 21 Feb 2025, at 00:51, Jonathan Wakely via Std-Proposals &lt;<a href="mailto:std-proposals@lists.isocpp.org" target="_blank">std-proposals@lists.isocpp.org</a>&gt; wrote:<br>
&gt; &gt; <br>
&gt; &gt; On Thu, 20 Feb 2025, 21:39 Phil Bouchard, &lt;<a href="mailto:boost@fornux.com" target="_blank">boost@fornux.com</a>&gt; wrote:<br>
&gt; &gt; <br>
&gt; &gt; On 2/20/25 16:19, Jonathan Wakely wrote:<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; On Thu, 20 Feb 2025 at 20:41, Phil Bouchard via Std-Proposals <br>
&gt; &gt; &gt; &lt;<a href="mailto:std-proposals@lists.isocpp.org" target="_blank">std-proposals@lists.isocpp.org</a> &lt;mailto:<a href="mailto:std-proposals@lists.isocpp.org" target="_blank">std-proposals@lists.isocpp.org</a>&gt;&gt; <br>
&gt; &gt; &gt; wrote:<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt;     regex_match would get 1 more character on the need basis using in.get()<br>
&gt; &gt; &gt;     quite simply. If it fails then it would rewind the read pointer to<br>
&gt; &gt; &gt;     where<br>
&gt; &gt; &gt;     it was.<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; How? iostream putback is extremely limited.<br>
&gt; &gt; <br>
&gt; &gt; Using seekg().<br>
&gt; &gt; <br>
&gt; &gt; That might work on an ifstream or istringstream but not on an arbitrary istream.<br>
&gt; <br>
&gt; It is as necessary to have a buffer of an arbitrarily large size for regexes, as the underlying theory for regular expressions just tells whether a string is in the language or not, and cannot tell when to stop. Examples are expressions like a|a*b, where on a string a… followed by something else than b, all but the first ‘a’ must be put back into the buffer. (Or some similar idea.)<br>
&gt; <br>
&gt; So when starting with parsers, the one character put back rule is no longer useful:<br>
&gt; <br>
&gt; One other example is when reading UTF-32 characters from a UTF-8 stream: Then one in general cannot put back the UTF-32 character, as it will in general occupy mora than one byte.<br>
&gt; <br>
&gt; <br>
&gt; Which is why you don&#39;t want to build it on top of a single-pass range, like an istream.<br>
<br>
One can have a single-pass buffered input stream, only that the buffer is larger than one character, which is what Flex does. Or like the other C++ formatted input already present, for different types, int&#39;s, floats, and strings, where you can&#39;t put back characters.</blockquote><div><br></div><div>But if you require a specific kind of buffered input stream (or even just a specific kind of streambuf with an arbitrary size putback area) then it&#39;s not a generic std::istream and so you don&#39;t want a operator&gt;&gt; overload that works with arbitrary std::istream objects.</div></div></div>

