GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::basic_ios::copyfmt(3) C++ Standard Libary std::basic_ios::copyfmt(3)

std::basic_ios::copyfmt - std::basic_ios::copyfmt


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:


1) Calls every callback registered by register_callback() passing erase_event as
parameter
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.
3) Calls every callback registered by register_callback() passing copyfmt_event as
parameter
4) Copies the exception mask from other to *this as if by calling
exceptions(other.exceptions())


other - another stream to use as source


*this


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.


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

// Run this code


#include <iostream>
#include <fstream>


int main()
{
std::ofstream out;


out.copyfmt(std::cout); // copy everything except rdstate and rdbuf
out.clear(std::cout.rdstate()); // copy rdstate
out.basic_ios<char>::rdbuf(std::cout.rdbuf()); // share the buffer


out << "Hello, world\n";
}


Hello, world

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.