std::basic_filebuf::operator=
来自cppreference.com
< cpp | io | basic filebuf
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
std::basic_filebuf& operator=( std::basic_filebuf&& rhs ); |
(C++11 起) | |
std::basic_filebuf& operator=( const std::basic_filebuf& rhs ) = delete; |
||
首先调用
2) close()
关闭相关的文件,然后将内容rhs
到*this
:put和get缓冲区,相关的文件,语言环境,用于openmode,IS_OPEN标志,和任何其他国家。移动后,rhs
是不相关的文件和rhs.is_open() == false.原文:
First calls
close()
to close the associated file, then moves the contents of rhs
into *this
: the put and get buffers, the associated file, the locale, the openmode, the is_open flag, and any other state. After the move, rhs
is not associated with a file and rhs.is_open() == false.拷贝赋值运算符被删除;
basic_filebuf
是不CopyAssignable
.原文:
The copy assignment operator is deleted;
basic_filebuf
is not CopyAssignable
.目录 |
[编辑] 参数
rhs | - | 另一个
basic_filebuf 将移动原文: another basic_filebuf that will be moved from |
[编辑] 返回值
*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对象 (公共成员函数) | |
(C++11) |
交换两个basic_filebuf对象 (公共成员函数) |