名前空間
変種
操作

std::basic_filebuf<CharT,Traits>::operator=

提供: cppreference.com
< cpp‎ | io‎ | basic filebuf
 
 
入出力ライブラリ
入出力マニピュレータ
Cスタイルの入出力
バッファ
(C++98で非推奨)
ストリーム
抽象
ファイル入出力
文字列入出力
配列入出力
(C++98で非推奨)
(C++98で非推奨)
(C++98で非推奨)
同期化出力
エラーカテゴリインタフェース
(C++11)
 
 
(C++11以上)
std::basic_filebuf& operator=( const std::basic_filebuf& rhs ) = delete;

別の basic_filebuf オブジェクトを代入します。

1) まず紐付けられているファイルを閉じるために close() を呼び、その後 rhs の内容 (put および get バッファ、紐付けられているファイル、ロケール、オープンモード、 is_open フラグ、およびその他のあらゆる状態) を *this にムーブします。 ムーブ後、 rhs はファイル紐付けられなくなり、 rhs.is_open() == false になります。
2) コピー代入演算子は削除されています。 basic_filebufCopyAssignable ではありません。

目次

[編集] 引数

rhs - ムーブされる別の basic_filebuf

[編集] 戻り値

*this

[編集]

#include <fstream>
#include <string>
#include <iostream>
 
int main()
{
 
    std::ifstream fin("test.in"); // read-only
    std::ofstream fout("test.out"); // write-only
 
    std::string s;
    getline(fin, s);
    std::cout << s << '\n'; // output
 
    *fin.rdbuf() = std::move(*fout.rdbuf());
 
    getline(fin, s);
    std::cout << s << '\n'; // empty line
 
    std::cout << std::boolalpha << fout.is_open() << '\n'; // prints "false"
 
}


[編集] 関連項目

basic_filebuf オブジェクトを構築します
(パブリックメンバ関数) [edit]
(C++11)
2つの basic_filebuf オブジェクトを入れ替えます
(パブリックメンバ関数) [edit]