A RetroSearch Logo

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

Search Query:

Showing content from https://cplusplus.com/reference/ios/basic_ios/copyfmt/ below:

public member function

<ios> <iostream>

std::basic_ios::copyfmt
basic_ios& copyfmt (const basic_ios& rhs);

Copy formatting information

Copies the values of all the internal members of rhs (except the state flags and the associated stream buffer) to the corresponding members of *this.

After the call, the following member functions return the same for rhs and *this:



* Each stream object keeps its own copy of the

internal extensible array

(

iword

,

pword

): Its contents are copied, not just a pointer to it.


* Each stream object keeps its own copy of the

internal extensible array

(

iword

,

pword

): Its contents are copied, not just a pointer to it.

If any of the pointer values to be copied points to objects stored outside rhs and those objects are destroyed when rhs is destroyed, *this stores instead pointers to newly constructed copies of these objects.



Calling this function invokes all functions registered through member register_callback twice: First, before the copying process starts, the function calls each registered callback fn using (*fn)(erase_event,*this,index). Then, at the end, right before the exceptions mask is copied, the function calls each registered callback fn wirh (*fn)(copyfmt_event,*this,index) (this second round can be used, for example, to access and modify the copied internal extensible array).

Parameters
rhs
Stream object whose members are copied to *this.

Return Value*this
Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// copying formatting information
#include <iostream>     // std::cout
#include <fstream>      // std::ofstream

int main () {
  std::ofstream filestr;
  filestr.open ("test.txt");

  std::cout.fill ('*');
  std::cout.width (10);
  filestr.copyfmt (std::cout);

  std::cout << 40;
  filestr << 40;

  return 0;
}

This example outputs a number formatted in the same way to both cout and a file called "test.txt":


Data races Modifies the stream object (*this), and accesses rhs.
Concurrent access to any of the objects may cause data races.

Exception safetyBasic guarantee: if an exception is thrown, the stream is in a valid state.

See also
basic_ios::tie
Get/set tied stream (public member function)
basic_ios::fill
Get/set fill character (public member function)
ios_base::width
Get/set field width (public member function)
ios_base::fmtflags
Type for stream format flags (public member type)

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