std::basic_filebuf<CharT,Traits>::operator= (3) - Linux Manuals
std::basic_filebuf<CharT,Traits>::operator=: std::basic_filebuf<CharT,Traits>::operator=
Command to display std::basic_filebuf<CharT,Traits>::operator=
manual in Linux: $ man 3 std::basic_filebuf<CharT,Traits>::operator=
NAME
std::basic_filebuf<CharT,Traits>::operator= - std::basic_filebuf<CharT,Traits>::operator=
Synopsis
std::basic_filebuf& operator=( std::basic_filebuf&& rhs ); (since C++11)
std::basic_filebuf& operator=( const std::basic_filebuf& rhs ) = delete;
Assigns another basic_filebuf object.
1) 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.
2) The copy assignment operator is deleted; basic_filebuf is not CopyAssignable.
Parameters
rhs - another basic_filebuf that will be moved from
Return value
*this
Example
// 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"
}
See also
constructs a basic_filebuf object
constructor (public member function)
swap swaps two basic_filebuf objects
(public member function)
(C++11)
Pages related to std::basic_filebuf<CharT,Traits>::operator=
- std::basic_filebuf<CharT,Traits>::open (3) - std::basic_filebuf<CharT,Traits>::open
- std::basic_filebuf<CharT,Traits>::overflow (3) - std::basic_filebuf<CharT,Traits>::overflow
- std::basic_filebuf<CharT,Traits>::basic_filebuf (3) - std::basic_filebuf<CharT,Traits>::basic_filebuf
- std::basic_filebuf<CharT,Traits>::close (3) - std::basic_filebuf<CharT,Traits>::close
- std::basic_filebuf<CharT,Traits>::imbue (3) - std::basic_filebuf<CharT,Traits>::imbue
- std::basic_filebuf<CharT,Traits>::is_open (3) - std::basic_filebuf<CharT,Traits>::is_open
- std::basic_filebuf<CharT,Traits>::pbackfail (3) - std::basic_filebuf<CharT,Traits>::pbackfail
- std::basic_filebuf<CharT,Traits>::seekoff (3) - std::basic_filebuf<CharT,Traits>::seekoff
- std::basic_filebuf<CharT,Traits>::seekpos (3) - std::basic_filebuf<CharT,Traits>::seekpos
- std::basic_filebuf<CharT,Traits>::setbuf (3) - std::basic_filebuf<CharT,Traits>::setbuf
- std::basic_filebuf<CharT,Traits>::showmanyc (3) - std::basic_filebuf<CharT,Traits>::showmanyc
- std::basic_filebuf<CharT,Traits>::swap (3) - std::basic_filebuf<CharT,Traits>::swap
- std::basic_filebuf<CharT,Traits>::sync (3) - std::basic_filebuf<CharT,Traits>::sync
- std::basic_filebuf<CharT,Traits>::uflow (3) - std::basic_filebuf<CharT,Traits>::uflow
- std::basic_filebuf<CharT,Traits>::underflow (3) - std::basic_filebuf<CharT,Traits>::underflow
- std::basic_filebuf<CharT,Traits>::~basic_filebuf (3) - std::basic_filebuf<CharT,Traits>::~basic_filebuf
- std::basic_filebuf (3) - std::basic_filebuf
- std::basic_fstream (3) - std::basic_fstream