A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/language/../../cpp/../cpp/io/ios_base/../basic_ios/copyfmt.html below:

std::basic_ios<CharT,Traits>::copyfmt - cppreference.com

basic_ios& copyfmt( const basic_ios& other );

If other refers to the same object as *this, has no effects. Otherwise, copies the state of the stream other into *this. This is done in the following sequence:

2)

Copies all member objects from

other

to

*this

except for

rdstate()

, the exception mask, and

rdbuf()

. In particular, makes copies of the locale, the formatting flags, the contents of the arrays

std::ios_base::iword

and

std::ios_base::pword

(but not the

iword

and

pword

pointers themselves), the callbacks, and the tied stream.

4) Copies the exception mask from other to *this as if by calling exceptions(other.exceptions()).

[edit] Parameters other - another stream to use as source [edit] Return value

*this

[edit] Notes

The second pass through the callbacks may be used to deep-copy the user-defined objects pointed to by the pointers in std::ios_base::pword.

copyfmt() may be used to save and restore the state of a stream. Boost provides a more fine-grained I/O state savers library for the same purpose.

[edit] Example

Makes the std::ofstream object "out" behave exactly like std::cout, including formatting, tie() to std::cin, etc.

Possible output:

Hello, world
1) out2.flags(): 00000000000000000001000000000010
2) cout.flags(): 00000000000000000001000000000010
3) cout.flags(): 00000000000000000001000000001111
4) out2.flags(): 00000000000000000001000000001111
[edit] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior LWG 256 C++98 step 3 called the registered callbacks with the
event type copy_event, which is not defined corrected to
copyfmt_event LWG 292 C++98 if other refers to the same object as *this, the member objects
were still copied and the registered callbacks were still called do nothing
in this case

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4