It is used to exchanges all internal data between x and *this.
DeclarationFollowing is the declaration for fstream::swap.
C++11void swap (basic_fstream& x);Parameters
x − Another basic_fstream object of the same type (i.e., with the same template parameters charT and traits).
Return Valuenone
ExceptionsNo-throw guarantee − this member function never throws exceptions.
Data racesIt modifies both stream objects (*this and x).
ExampleIn below example explains about fstream swap function.
#include <fstream> int main () { std::fstream foo; std::fstream bar ("test.txt"); foo.swap(bar); foo << "lorem ipsum"; foo.close(); return 0; }
fstream.htm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4