Topic: IO state manipulators


Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Thu, 18 Sep 2014 04:31:02 -0700 (PDT)
Raw View
------=_Part_1420_1401022994.1411039862962
Content-Type: text/plain; charset=UTF-8

What do people feel about adding IO manipulators like:

std::savestatus(st) and std::restorestatus(st)

where st is of type is_status, given below:

namespace std {
  struct io_status { /* ... */ };
}

This would save and restore the state (width, precision, base, etc, but not
eof_bit, fail_bit, error_bit).

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_1420_1401022994.1411039862962
Content-Type: text/html; charset=UTF-8

<div dir="ltr"><DIV>What do people feel about adding IO manipulators like:</DIV>
<DIV>&nbsp;</DIV>
<DIV>std::savestatus(st) and std::restorestatus(st)</DIV>
<DIV>&nbsp;</DIV>
<DIV>where st is of type is_status, given below:</DIV>
<DIV>&nbsp;</DIV>
<DIV>namespace std {</DIV>
<DIV>&nbsp; struct io_status { /* ... */ };</DIV>
<DIV>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>This would save and restore the state (width, precision, base, etc, but not eof_bit, fail_bit, error_bit).</DIV></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href="mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />

------=_Part_1420_1401022994.1411039862962--

.


Author: Jonathan Coe <jonathanbcoe@gmail.com>
Date: Thu, 18 Sep 2014 14:22:50 +0100
Raw View
--Apple-Mail-A6309F16-9A45-4065-A4EE-F86EB8257F4B
Content-Type: text/plain; charset=ISO-8859-1

This sounds very useful to me



> On 18 Sep 2014, at 12:31, Douglas Boffey <douglas.boffey@gmail.com> wrote:
>
> What do people feel about adding IO manipulators like:
>
> std::savestatus(st) and std::restorestatus(st)
>
> where st is of type is_status, given below:
>
> namespace std {
>   struct io_status { /* ... */ };
> }
>
> This would save and restore the state (width, precision, base, etc, but not eof_bit, fail_bit, error_bit).
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--Apple-Mail-A6309F16-9A45-4065-A4EE-F86EB8257F4B
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=
=3Dutf-8"></head><body dir=3D"auto"><div>This sounds very useful to me&nbsp=
;<br><br><br></div><div><br>On 18 Sep 2014, at 12:31, Douglas Boffey &lt;<a=
 href=3D"mailto:douglas.boffey@gmail.com">douglas.boffey@gmail.com</a>&gt; =
wrote:<br><br></div><blockquote type=3D"cite"><div><div dir=3D"ltr"><div>Wh=
at do people feel about adding IO manipulators like:</div>
<div>&nbsp;</div>
<div>std::savestatus(st) and std::restorestatus(st)</div>
<div>&nbsp;</div>
<div>where st is of type is_status, given below:</div>
<div>&nbsp;</div>
<div>namespace std {</div>
<div>&nbsp; struct io_status { /* ... */ };</div>
<div>}</div>
<div>&nbsp;</div>
<div>This would save and restore the state (width, precision, base, etc, bu=
t not eof_bit, fail_bit, error_bit).</div></div>

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br>
</div></blockquote></body></html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--Apple-Mail-A6309F16-9A45-4065-A4EE-F86EB8257F4B--

.


Author: David Krauss <potswa@gmail.com>
Date: Thu, 18 Sep 2014 23:41:10 +0800
Raw View
--Apple-Mail=_1CA5F3BD-10A5-4038-9ED4-03A3386F5DE1
Content-Type: text/plain; charset=ISO-8859-1


On 2014-09-18, at 7:31 PM, Douglas Boffey <douglas.boffey@gmail.com> wrote:

> What do people feel about adding IO manipulators like:
>
> std::savestatus(st) and std::restorestatus(st)
>
> where st is of type is_status, given below:
>
> namespace std {
>   struct io_status { /* ... */ };
> }
>
> This would save and restore the state (width, precision, base, etc, but not eof_bit, fail_bit, error_bit).

That's the standard formatting state, but I think "status" sounds like a misnomer.

You might want to look into basic_ios::copyfmt, move, and swap. I think the intent is along these lines:

std::istream fmtback( nullptr );
fmtback.copyfmt( std::cout ); // Save initial state.

std::cout << std::hex << std::noboolalpha << ... ; // Change state.
// Print some things.

std::cout.swap( fmtback ); // Restore state.

There could be a copyfmt manipulator, but it might be just as well not to put too much on one line.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--Apple-Mail=_1CA5F3BD-10A5-4038-9ED4-03A3386F5DE1
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;09&ndash;18, at 7:31 PM, Douglas Boffey &lt;<a href=3D"mailto:douglas=
..boffey@gmail.com">douglas.boffey@gmail.com</a>&gt; wrote:</div><br class=
=3D"Apple-interchange-newline"><blockquote type=3D"cite"><div dir=3D"ltr"><=
div>What do people feel about adding IO manipulators like:</div>
<div>&nbsp;</div>
<div>std::savestatus(st) and std::restorestatus(st)</div>
<div>&nbsp;</div>
<div>where st is of type is_status, given below:</div>
<div>&nbsp;</div>
<div>namespace std {</div>
<div>&nbsp; struct io_status { /* ... */ };</div>
<div>}</div>
<div>&nbsp;</div>
<div>This would save and restore the state (width, precision, base, etc, bu=
t not eof_bit, fail_bit, error_bit).</div></div></blockquote><div><br></div=
><div>That&rsquo;s the standard formatting state, but I think &ldquo;status=
&rdquo; sounds like a misnomer.</div><div><br></div><div>You might want to =
look into <font face=3D"Courier">basic_ios::copyfmt</font>, <font face=3D"C=
ourier">move</font>, and <font face=3D"Courier">swap</font>. I think the in=
tent is along these lines:</div><div><br></div><div><font face=3D"Courier">=
std::istream fmtback( nullptr );</font></div><div><span style=3D"font-famil=
y: Courier;">fmtback.copyfmt( std::cout ); // Save initial state.</span></d=
iv><div><span style=3D"font-family: Courier;"><br></span></div><div><font f=
ace=3D"Courier">std::cout &lt;&lt; std::hex &lt;&lt; std::noboolalpha &lt;&=
lt; &hellip; ; // Change state.</font></div><div><font face=3D"Courier">// =
Print some things.</font></div><div><font face=3D"Courier"><br></font></div=
><div><font face=3D"Courier">std::cout.swap( fmtback ); // Restore state.</=
font></div><div><br></div><div>There could be a <font face=3D"Courier">copy=
fmt</font> manipulator, but it might be just as well not to put too much on=
 one line.</div><div><br></div></div></body></html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--Apple-Mail=_1CA5F3BD-10A5-4038-9ED4-03A3386F5DE1--

.


Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Wed, 24 Sep 2014 19:09:07 -0400
Raw View
On 2014-09-18 07:31, Douglas Boffey wrote:
> What do people feel about adding IO manipulators like:
>
> std::savestatus(st) and std::restorestatus(st)

It might be worth considering how often you really need to work with
such state objects vs. how often you just want to push/pop state, which
might be easier to get standardized and/or more convenient.

I can easily see some way to fiddle with the state and then put it back
to how it was being useful :-).

--
Matthew

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: John Bytheway <jbytheway@gmail.com>
Date: Thu, 25 Sep 2014 17:33:55 -0400
Raw View
On 2014-09-24 19:09, Matthew Woehlke wrote:
> On 2014-09-18 07:31, Douglas Boffey wrote:
>> What do people feel about adding IO manipulators like:
>>
>> std::savestatus(st) and std::restorestatus(st)
>
> It might be worth considering how often you really need to work with
> such state objects vs. how often you just want to push/pop state, which
> might be easier to get standardized and/or more convenient.
>
> I can easily see some way to fiddle with the state and then put it back
> to how it was being useful :-).

....and an RAII-esque solution which restored state in its destructor
would be a natural way to achieve that.  Sounds useful to me.

John Bytheway

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Jan Herrmann <jherrmann79@gmx.de>
Date: Fri, 26 Sep 2014 08:15:23 +0200
Raw View
On 18.09.2014 13:31, Douglas Boffey wrote:
> What do people feel about adding IO manipulators like:
>
> std::savestatus(st) and std::restorestatus(st)
>
> where st is of type is_status, given below:
>
> namespace std {
>    struct io_status { /* ... */ };
> }
>
> This would save and restore the state (width, precision, base, etc, but not
> eof_bit, fail_bit, error_bit).
>

There is I/O Stream-State Saver Library
(http://www.boost.org/doc/libs/1_56_0/libs/io/doc/ios_state.html) in
boost. This could be used as a starting point.

Jan Herrmann

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Jim Porter <jvp4846@g.rit.edu>
Date: Fri, 26 Sep 2014 01:47:38 -0500
Raw View
On 9/25/2014 4:33 PM, John Bytheway wrote:
> On 2014-09-24 19:09, Matthew Woehlke wrote:
>> On 2014-09-18 07:31, Douglas Boffey wrote:
>>> What do people feel about adding IO manipulators like:
>>>
>>> std::savestatus(st) and std::restorestatus(st)
>>
>> It might be worth considering how often you really need to work with
>> such state objects vs. how often you just want to push/pop state, which
>> might be easier to get standardized and/or more convenient.
>>
>> I can easily see some way to fiddle with the state and then put it back
>> to how it was being useful :-).
>
> ...and an RAII-esque solution which restored state in its destructor
> would be a natural way to achieve that.  Sounds useful to me.
>
> John Bytheway
>

That sounds pretty similar to how I manage indentation in some code of
mine[1]:

   out << "some text" << std::endl;
   if(!message.empty()) {
     scoped_indent si(out);
     out << message << std::endl;
   }

I've found it pretty useful so far. (Although the indentation does
require a custom streambuf). While I'd probably be even happier to see
IO manipulators go away (and be replaced with something printf-like),
being able to push and pop the state would be a big help.

- Jim

[1]
https://github.com/jimporter/mettle/blob/master/include/mettle/log/indent.hpp#L73-L91

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: David Krauss <potswa@gmail.com>
Date: Fri, 26 Sep 2014 16:40:31 +0800
Raw View
--Apple-Mail=_6A894CFF-4846-4E70-AD2A-004D48537CBD
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1


On 2014-09-26, at 2:47 PM, Jim Porter <jvp4846@g.rit.edu> wrote:

> That sounds pretty similar to how I manage indentation in some code of mi=
ne[1]:
>=20
>  out << "some text" << std::endl;
>  if(!message.empty()) {
>    scoped_indent si(out);
>    out << message << std::endl;
>  }
>=20
> I've found it pretty useful so far. (Although the indentation does requir=
e a custom streambuf). While I'd probably be even happier to see IO manipul=
ators go away (and be replaced with something printf-like), being able to p=
ush and pop the state would be a big help.

Indentation is easier to do with custom manipulators.

On one hand, you have to use the new manipulators to get new behavior -- it=
's not a retrofit. On the other hand, the stream buffer accomplishes a retr=
ofit by changing the output encoding, which is a bit of low-level hackery a=
nd might not be compatible with everything.


#include <iostream>

inline long & indentation_level( std::ostream & s ) {
    static int const iword =3D std::ios_base::xalloc();
    return s.iword( iword );
}

inline std::ostream & indent( std::ostream & s ) {
    ++ indentation_level( s );
    return s;
}

inline std::ostream & unindent( std::ostream & s ) {
    -- indentation_level( s );
    return s;
}

inline std::ostream & justify( std::ostream & s ) {
    for ( int cnt =3D 0, level =3D indentation_level( s ); cnt !=3D level; =
++ cnt ) {
        s << '\t';
    }
    return s;
}

inline std::ostream & nextline( std::ostream & s ) {
    s << '\n' << justify;
    return s;
}

class scope_indentation {
    std::ostream & s;
public:
    explicit scope_indentation( std::ostream & in_s )
        : s( in_s )
        { s << indent; }

    ~ scope_indentation()
        { s << unindent; }
};

int main() {
    std::cout << "hello";
    {
        scope_indentation si( std::cout );
        std::cout << nextline << "world";
    }
    std::cout << nextline << "!\n";
}

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--Apple-Mail=_6A894CFF-4846-4E70-AD2A-004D48537CBD
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;09&ndash;26, at 2:47 PM, Jim Porter &lt;<a href=3D"mailto:jvp4846@g.r=
it.edu">jvp4846@g.rit.edu</a>&gt; wrote:</div><br class=3D"Apple-interchang=
e-newline"><blockquote type=3D"cite"><div style=3D"font-size: 12px; font-st=
yle: normal; font-variant: normal; font-weight: normal; letter-spacing: nor=
mal; line-height: normal; orphans: auto; text-align: start; text-indent: 0p=
x; text-transform: none; white-space: normal; widows: auto; word-spacing: 0=
px; -webkit-text-stroke-width: 0px;">That sounds pretty similar to how I ma=
nage indentation in some code of mine[1]:<br><br>&nbsp;out &lt;&lt; "some t=
ext" &lt;&lt; std::endl;<br>&nbsp;if(!message.empty()) {<br>&nbsp;&nbsp;&nb=
sp;scoped_indent si(out);<br>&nbsp;&nbsp;&nbsp;out &lt;&lt; message &lt;&lt=
; std::endl;<br>&nbsp;}<br><br>I've found it pretty useful so far. (Althoug=
h the indentation does require a custom streambuf). While I'd probably be e=
ven happier to see IO manipulators go away (and be replaced with something =
printf-like), being able to push and pop the state would be a big help.<br>=
</div></blockquote><div><br></div><div>Indentation is easier to do with cus=
tom manipulators.</div><div><br></div><div>On one hand, you have to use the=
 new manipulators to get new behavior &mdash; it&rsquo;s not a retrofit. On=
 the other hand, the stream buffer accomplishes a retrofit by changing the =
output encoding, which is a bit of low-level hackery and might not be compa=
tible with everything.</div><div><br></div><div><br></div><div><div><font f=
ace=3D"Courier">#include &lt;iostream&gt;</font></div><div><font face=3D"Co=
urier"><br></font></div><div><font face=3D"Courier">inline long &amp; inden=
tation_level( std::ostream &amp; s ) {</font></div><div><font face=3D"Couri=
er">&nbsp; &nbsp; static int const iword =3D std::ios_base::xalloc();</font=
></div><div><font face=3D"Courier">&nbsp; &nbsp; return s.iword( iword );</=
font></div><div><font face=3D"Courier">}</font></div><div><font face=3D"Cou=
rier"><br></font></div><div><font face=3D"Courier">inline std::ostream &amp=
; indent( std::ostream &amp; s ) {</font></div><div><font face=3D"Courier">=
&nbsp; &nbsp; ++ indentation_level( s );</font></div><div><font face=3D"Cou=
rier">&nbsp; &nbsp; return s;</font></div><div><font face=3D"Courier">}</fo=
nt></div><div><font face=3D"Courier"><br></font></div><div><font face=3D"Co=
urier">inline std::ostream &amp; unindent( std::ostream &amp; s ) {</font><=
/div><div><font face=3D"Courier">&nbsp; &nbsp; -- indentation_level( s );</=
font></div><div><font face=3D"Courier">&nbsp; &nbsp; return s;</font></div>=
<div><font face=3D"Courier">}</font></div><div><font face=3D"Courier"><br><=
/font></div><div><font face=3D"Courier">inline std::ostream &amp; justify( =
std::ostream &amp; s ) {</font></div><div><font face=3D"Courier">&nbsp; &nb=
sp; for ( int cnt =3D 0, level =3D indentation_level( s ); cnt !=3D level; =
++ cnt ) {</font></div><div><font face=3D"Courier">&nbsp; &nbsp; &nbsp; &nb=
sp; s &lt;&lt; '\t';</font></div><div><font face=3D"Courier">&nbsp; &nbsp; =
}</font></div><div><font face=3D"Courier">&nbsp; &nbsp; return s;</font></d=
iv><div><font face=3D"Courier">}</font></div><div><font face=3D"Courier"><b=
r></font></div><div><font face=3D"Courier">inline std::ostream &amp; nextli=
ne( std::ostream &amp; s ) {</font></div><div><font face=3D"Courier">&nbsp;=
 &nbsp; s &lt;&lt; '\n' &lt;&lt; justify;</font></div><div><font face=3D"Co=
urier">&nbsp; &nbsp; return s;</font></div><div><font face=3D"Courier">}</f=
ont></div><div><font face=3D"Courier"><br></font></div><div><font face=3D"C=
ourier">class scope_indentation {</font></div><div><font face=3D"Courier">&=
nbsp; &nbsp; std::ostream &amp; s;</font></div><div><font face=3D"Courier">=
public:</font></div><div><font face=3D"Courier">&nbsp; &nbsp; explicit scop=
e_indentation( std::ostream &amp; in_s )</font></div><div><font face=3D"Cou=
rier">&nbsp; &nbsp; &nbsp; &nbsp; : s( in_s )</font></div><div><font face=
=3D"Courier">&nbsp; &nbsp; &nbsp; &nbsp; { s &lt;&lt; indent; }</font></div=
><div><font face=3D"Courier"><br></font></div><div><font face=3D"Courier">&=
nbsp; &nbsp; ~ scope_indentation()</font></div><div><font face=3D"Courier">=
&nbsp; &nbsp; &nbsp; &nbsp; { s &lt;&lt; unindent; }</font></div><div><font=
 face=3D"Courier">};</font></div><div><font face=3D"Courier"><br></font></d=
iv><div><font face=3D"Courier">int main() {</font></div><div><font face=3D"=
Courier">&nbsp; &nbsp; std::cout &lt;&lt; "hello";</font></div><div><font f=
ace=3D"Courier">&nbsp; &nbsp; {</font></div><div><font face=3D"Courier">&nb=
sp; &nbsp; &nbsp; &nbsp; scope_indentation si( std::cout );</font></div><di=
v><font face=3D"Courier">&nbsp; &nbsp; &nbsp; &nbsp; std::cout &lt;&lt; nex=
tline &lt;&lt; "world";</font></div><div><font face=3D"Courier">&nbsp; &nbs=
p; }</font></div><div><font face=3D"Courier">&nbsp; &nbsp; std::cout &lt;&l=
t; nextline &lt;&lt; "!\n";</font></div><div><font face=3D"Courier">}</font=
></div><div><br></div></div></div></body></html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--Apple-Mail=_6A894CFF-4846-4E70-AD2A-004D48537CBD--

.


Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Fri, 26 Sep 2014 07:27:20 -0700 (PDT)
Raw View
------=_Part_493_1094761698.1411741640984
Content-Type: text/plain; charset=UTF-8

Thanks for your replies.

Regarding the name, I agree that 'state' is not the best choice.  A better
choice, IMO, would besave_format and restore format.
As for pushing/poping on a stack, I am not convinced (maybe as a parallel
proposal?)  Take, for example, the problem where you have a function that
needs to write two columns of data, each with their respective formats.
This would be impossible with a stack based implementation.

Again, if one member function of a class needed to store the format (e.g.
the ctor) for another member function, there would be no guarantee that the
correct format would be on the top of the stack for the second member
function to use.

I admit, sometimes I do resort to the printf family of functions for their
ease of use over streams, and rely on -Wformat.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_493_1094761698.1411741640984
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><DIV>Thanks for your replies.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Regarding the name, I agree that 'state' is not the best choice.&nbsp;=
 A better choice, IMO, would besave_format and restore format.<BR></DIV>
<DIV>As for pushing/poping on a stack, I am not convinced (maybe as a paral=
lel proposal?)&nbsp; Take, for example, the problem where you have a functi=
on that needs to write two columns of data, each with their respective form=
ats.&nbsp; This would be impossible with a stack based implementation.</DIV=
>
<DIV>&nbsp;</DIV>
<DIV>Again, if one member function of a class&nbsp;needed to store the form=
at (e.g. the ctor) for another&nbsp;member function, there would be no guar=
antee that the correct format would be on the top of the stack for the seco=
nd member function to use.</DIV>
<DIV>&nbsp;</DIV>
<DIV>I admit, sometimes I do resort to the printf family of functions for t=
heir ease of use over streams, and rely on -Wformat.</DIV></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_493_1094761698.1411741640984--

.


Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Fri, 26 Sep 2014 13:24:53 -0400
Raw View
On 2014-09-26 10:27, Douglas Boffey wrote:
> As for pushing/poping on a stack, I am not convinced (maybe as a parallel
> proposal?)  Take, for example, the problem where you have a function that
> needs to write two columns of data, each with their respective formats.
> This would be impossible with a stack based implementation.

Yes, I think having an RAII helper class to save the state / set it
temporarily would be better in general. The down side is you can't
inject it in the middle of a series of stream operations, but the other
benefits seem to outweigh that.

> I admit, sometimes I do resort to the printf family of functions for their
> ease of use over streams, and rely on -Wformat.

Yeah... I never liked stream formatting in C++. Give me printf-style any
day :-). (At least we're also slowly approaching STL having similar
facilities as QString::number, which also helps.)

--
Matthew

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Jim Porter <jvp4846@g.rit.edu>
Date: Fri, 26 Sep 2014 12:58:51 -0500
Raw View
On 9/26/2014 3:40 AM, David Krauss wrote:
>
> On 2014-09-26, at 2:47 PM, Jim Porter <jvp4846@g.rit.edu
> <mailto:jvp4846@g.rit.edu>> wrote:
>
>> That sounds pretty similar to how I manage indentation in some code of
>> mine[1]:
>>
>>  out << "some text" << std::endl;
>>  if(!message.empty()) {
>>    scoped_indent si(out);
>>    out << message << std::endl;
>>  }
>>
>> I've found it pretty useful so far. (Although the indentation does
>> require a custom streambuf). While I'd probably be even happier to see
>> IO manipulators go away (and be replaced with something printf-like),
>> being able to push and pop the state would be a big help.
>
> Indentation is easier to do with custom manipulators.
>
> On one hand, you have to use the new manipulators to get new behavior --
> it's not a retrofit. On the other hand, the stream buffer accomplishes a
> retrofit by changing the output encoding, which is a bit of low-level
> hackery and might not be compatible with everything.

At the risk of getting painfully off-topic, the reason I made a custom
streambuf was to indent multi-line std::strings, which requires
filtering the output somehow before it gets to its destination. A new
streambuf seemed like the best way to do it.

- Jim

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: "Mark A. Gibbs" <indi.in.the.wired@gmail.com>
Date: Fri, 26 Sep 2014 17:00:09 -0700 (PDT)
Raw View
------=_Part_1170_1552539173.1411776009973
Content-Type: text/plain; charset=UTF-8

I also like the idea of seeing something like the Boost RAII IO state
savers in the standard library. Perhaps the fine-grained control that the
Boost library offers is a bit much - perhaps there is only need of a single
"saver" class that just saves "everything" in the stream (ie, just the
"ios_base_all_saver" and "basic_ios_all_saver" classes from Boost).

The Boost IO state saver library is one of the libraries I use most,
because I do a lot of parsing. In fact, I'm proposing a range I/O library
for the standard, and I had to duplicate the Boost functionality to make it
work (see here
<https://github.com/DarkerStar/cpp-range-streaming/blob/master/include/stream-formatting-saver.hpp>).
The manipulators proposed here would have saved me that work had they been
in the standard.

The one thing about the manipulator design that concerns me is what happens
when you use the same state object multiple times. I think calling
restorestatus/restoreformat multiple times would be harmless... but what
happens when you call savestatus/saveformat multiple times? For example:

// assume cout's width is 10 before the function
cout.width(10);

{
  auto s = io_status{}; // should default construction even be allowed?
                        // or should it always take a stream/ios/ios_base
arg?

  // like a good function, this function saves the state at the start and
  // restores it at the end.
  cout << savestatus(s);

  // the function changes the width for some reason
  cout.width(5);

  // ... looooooooong function... and somewhere in the middle, the state
needs
  // to be saved again.
  auto s2 = io_status{};
  cout << savestatus(s); // (whoops! meant to use s2, not s!)

  // ... stuff ...

  // Restore as part of the cleanup (but what if you forgot to do this,
  // or an exception was thrown? no restore in that case?)
  cout << restorestatus(s);
}

assert(cout.width() == 10); // Fail! Despite all the effort to save the
state

For the record, the Boost model is:

// assume cout's width is 10 before the function
cout.width(10);

{
  auto s = ios_all_saver{cout}; // state is saved immediately on
construction,
                                // and cannot be changed

  // the function changes the width for some reason
  cout.width(5);

  // ... looooooooong function... and somewhere in the middle, the state
needs
  // to be saved again.
  auto s2 = ios_all_saver{cout}; // impossible to screw up

  // ... stuff ...

  // Restore is automatic
}

assert(cout.width() == 10); // Safe

It's not as slick as the manipulator solution, but it's impossible to screw
up.

I don't think it's practical to use a manipulator to *save* the state...
but the *restore* part can be done by a manipulator. (Though I think it
should also be done by the state class's destructor.)

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_1170_1552539173.1411776009973
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I also like the idea of seeing something like the Boost RA=
II IO state savers in the standard library. Perhaps the fine-grained contro=
l that the Boost library offers is a bit much - perhaps there is only need =
of a single "saver" class that just saves "everything" in the stream (ie, j=
ust the "ios_base_all_saver" and "basic_ios_all_saver" classes from Boost).=
<br><br>The Boost IO state saver library is one of the libraries I use most=
, because I do a lot of parsing. In fact, I'm proposing a range I/O library=
 for the standard, and I had to duplicate the Boost functionality to make i=
t work (<a href=3D"https://github.com/DarkerStar/cpp-range-streaming/blob/m=
aster/include/stream-formatting-saver.hpp">see here</a>). The manipulators =
proposed here would have saved me that work had they been in the standard.<=
br><br>The one thing about the manipulator design that concerns me is what =
happens when you use the same state object multiple times. I think calling =
restorestatus/restoreformat multiple times would be harmless... but what ha=
ppens when you call savestatus/saveformat multiple times? For example:<br><=
br><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250)=
; border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px;=
 word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprett=
yprint"><span style=3D"color: #800;" class=3D"styled-by-prettify">// assume=
 cout's width is 10 before the function</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br>cout</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">width</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">(</span><span style=3D"color: #066;" class=3D"styled-by-pretti=
fy">10</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> s </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> io_status</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">{};</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"sty=
led-by-prettify">// should default construction even be allowed?</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><=
span style=3D"color: #800;" class=3D"styled-by-prettify">// or should it al=
ways take a stream/ios/ios_base arg?</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>&nbsp; <br>&nbsp; </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">// like a good function, this functio=
n saves the state at the start and</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color: #800;" clas=
s=3D"styled-by-prettify">// restores it at the end.</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>&nbsp; cout </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> savestatus</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">s</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>&nbsp; <br>&nbsp; </span><span style=3D"color: =
#800;" class=3D"styled-by-prettify">// the function changes the width for s=
ome reason</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>&nbsp; cout</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">widt=
h</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><=
span style=3D"color: #066;" class=3D"styled-by-prettify">5</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>&nbsp; <br>&nbsp; </span><span =
style=3D"color: #800;" class=3D"styled-by-prettify">// ... looooooooong fun=
ction... and somewhere in the middle, the state needs</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D=
"color: #800;" class=3D"styled-by-prettify">// to be saved again.</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> s2 </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> io_status</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">{};</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br>&nbsp; cout </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> savestatus</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">s</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">=
// (whoops! meant to use s2, not s!)</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>&nbsp; <br>&nbsp; </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">// ... stuff ...</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; <br>&nbsp; </span><s=
pan style=3D"color: #800;" class=3D"styled-by-prettify">// Restore as part =
of the cleanup (but what if you forgot to do this,</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"co=
lor: #800;" class=3D"styled-by-prettify">// or an exception was thrown? no =
restore in that case?)</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>&nbsp; cout </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> restorestatus</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">s</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">assert</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">cout</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">width</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">=3D=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #066;" class=3D"styled-by-prettify">10</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #800;" class=3D"styled-by-prettify">// Fail! Despite all the effort to s=
ave the state</span></div></code></div><br>For the record, the Boost model =
is:<br><br><div class=3D"prettyprint" style=3D"background-color: rgb(250, 2=
50, 250); border-color: rgb(187, 187, 187); border-style: solid; border-wid=
th: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"=
subprettyprint"><span style=3D"color: #800;" class=3D"styled-by-prettify">/=
/ assume cout's width is 10 before the function</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"><br>cout</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">width</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(</span><span style=3D"color: #066;" class=3D"styled-b=
y-prettify">10</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
<br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> s </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> ios_all_saver</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">cout</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">// state is saved immediately on construction,</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp;=
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp; &nbsp; </span><span style=3D"color: #800;" class=3D"styled-by-pre=
ttify">// and cannot be changed</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>&nbsp; <br>&nbsp; </span><span style=3D"color: #80=
0;" class=3D"styled-by-prettify">// the function changes the width for some=
 reason</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
>&nbsp; cout</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">width</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><spa=
n style=3D"color: #066;" class=3D"styled-by-prettify">5</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>&nbsp; <br>&nbsp; </span><span s=
tyle=3D"color: #800;" class=3D"styled-by-prettify">// ... looooooooong func=
tion... and somewhere in the middle, the state needs</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"=
color: #800;" class=3D"styled-by-prettify">// to be saved again.</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> s2 </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> ios_all_saver</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">cout</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-pr=
ettify">// impossible to screw up</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>&nbsp; <br>&nbsp; </span><span style=3D"color: =
#800;" class=3D"styled-by-prettify">// ... stuff ...</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>&nbsp; <br>&nbsp; </span><spa=
n style=3D"color: #800;" class=3D"styled-by-prettify">// Restore is automat=
ic</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">assert</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">cout</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">width</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">=3D=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #066;" class=3D"styled-by-prettify">10</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #800;" class=3D"styled-by-prettify">// Safe</span></div></code></div><br=
>It's not as slick as the manipulator solution, but it's impossible to scre=
w up.<br><br>I don't think it's practical to use a manipulator to <i>save</=
i> the state... but the <i>restore</i> part can be done by a manipulator. (=
Though I think it should also be done by the state class's destructor.)<br>=
</div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_1170_1552539173.1411776009973--

.