It exchanges the values of the fstream objects x and y.
DeclarationFollowing is the declaration for fstream::swap.
C++11template <class charT, class traits> void swap (basic_fstream<charT,traits>& x, basic_fstream<charT,traits>& y);Parameters
x,y − basic_fstream objects of the same type (i.e., having both the same template parameters, charT and traits).
none
ExceptionsNo-throw guarantee − this member function never throws exceptions.
Data racesBoth objects, x and y, are modified.
ExampleIn below example explains about fstream swap function.
#include <fstream> int main () { std::fstream foo; std::fstream bar ("test.txt"); swap(foo,bar); foo << "tutorialspoint"; 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