lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] [lmi-commits] master 7a6262f 5/5: Save and restore stream form


From: Vadim Zeitlin
Subject: Re: [lmi] [lmi-commits] master 7a6262f 5/5: Save and restore stream formatting more easily and correctly
Date: Tue, 3 Aug 2021 00:54:31 +0200

On Mon,  2 Aug 2021 18:25:16 -0400 (EDT) Greg Chicares 
<gchicares@sbcglobal.net> wrote:

GC> branch: master
GC> commit 7a6262fb9fe6baaf8a54d0d30731331ea4118f3e
GC> Author: Gregory W. Chicares <gchicares@sbcglobal.net>
GC> Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
GC> 
GC>     Save and restore stream formatting more easily and correctly
GC>     
GC>     This fixes a latent defect. Test your iostream knowledge by finding it:
GC>     
GC>     -    std::ios_base::fmtflags old_flags = std::cout.flags();
GC>     [...manipulators...]
GC>     -    std::cout.setf(old_flags);
GC>     
GC>     SPOILER:
GC>     
GC>     The one-argument version of the function called on the last line is not
GC>     equivalent to calling flags() with the same argument.

 It will be a lot less fun, but I'm looking forward to transitioning to
std::format in the near future. Unfortunately C++20 has standardized only a
part of fmt library and doesn't include any actual output functions, nor
compile-time format string checks, so it's still better to use the
standalone version of the library until C++23 hopefully includes it in its
entirety, but IME using fmt is so much nicer (== simpler and safer and
faster and more flexible) than using iostreams that it's really difficult
to even look at the code using iostreams after using it, let alone writing
it.

 Regards,
VZ

Attachment: pgpzL_Df6hnAl.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]