| I/O manipulators | ||||
| Print functions(C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++20) | ||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
| Synchronized Output | ||||
(C++20) | ||||
| Types | ||||
| Error category interface | ||||
(C++11) | ||||
(C++11) |
| Public member functions | ||||
basic_filebuf::operator= (C++11) | ||||
(C++11) | ||||
(C++26) | ||||
| Protected member functions | ||||
| Non-member functions | ||||
(C++11) |
std::basic_filebuf& operator=(std::basic_filebuf&& rhs); | (1) | (since C++11) |
std::basic_filebuf& operator=(conststd::basic_filebuf& rhs)= delete; | (2) | |
Assigns anotherbasic_filebuf object.
Contents |
| rhs | - | anotherbasic_filebuf that will be moved from |
*this
#include <cassert>#include <fstream>#include <iostream>#include <string> int main(){std::ofstream{"test.in"}<<"test\n";// writes via a temporary objectstd::ifstream fin("test.in");// read-only streamstd::ofstream fout("test.out");// write-only stream std::string s;std::getline(fin, s);std::cout<<"s = ["<< s<<"]\n";// s contains "test" assert(fout.is_open());*fin.rdbuf()= std::move(*fout.rdbuf());assert(!fout.is_open()); std::getline(fin, s);std::cout<<"s = ["<< s<<"]\n";// s is empty input}
Output:
s = [test]s = []
constructs abasic_filebuf object(public member function)[edit] | |
(C++11) | swaps twobasic_filebuf objects(public member function)[edit] |