Cpp-standard-library-cpp-ios-copyfmt

提供:Dev Guides
移動先:案内検索

C ++ IOSライブラリ-copyfmt

説明

rhsのすべての内部メンバーの値(状態フラグおよび関連するストリームバッファーを除く)を* thisの対応するメンバーにコピーします。

呼び出しの後、次のメンバー関数はrhsと *thisに対して同じを返します-

element description
flags format flags
width field width
precision precision
getloc selected locale
iarray internal extensible array*
parray internal extensible array *
fill fill character
tie tied stream
exceptions exceptions mask (last to be copied, see below)

宣言

以下は、ios
copyfmt関数の宣言です。
ios& copyfmt (const ios& rhs);

パラメーター

*rhs* -メンバーが* thisにコピーされるストリームオブジェクト。

戻り値

  • thisを返します。

例外

基本保証-例外がスローされた場合、ストリームは有効な状態です。

データの競合

ストリームオブジェクト(* this)を変更し、rhsにアクセスします。

オブジェクトへの同時アクセスは、データの競合を引き起こす可能性があります。

以下の例では、ios
copyfmt関数について説明しています。
#include <iostream>
#include <fstream>

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;
}

上記のプログラムをコンパイルして実行すると、次の結果が生成されます-

********40