std::basic_filebuf<CharT,Traits>::operator=
提供: cppreference.com
< cpp | io | basic filebuf
std::basic_filebuf& operator=( std::basic_filebuf&& rhs ); |
(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 になります。目次 |
[編集] 引数
rhs | - | ムーブされる別の basic_filebuf
|
[編集] 戻り値
*this
。
[編集] 例
Run this code
#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 オブジェクトを構築します (パブリックメンバ関数) | |
(C++11) |
2つの basic_filebuf オブジェクトを入れ替えます (パブリックメンバ関数) |