Trying to give an answer to this question text-file-handling-in-c giving references to cplusplus.com. I came across to the std::swap
-function for stream-types like fstream
.
So my question is: What exactly is the purpose of a swap functionality e.g. for a 'fstream' respectively in which situation do I have to use it?
Referencing to to the Q&A C++ std::ifstream in constructor problem I know that stream types are non-copyable. Referencing to the Q&A What is the copy-and-swap idiom? the swap-functionality is e.g. given to implement a copy-constructor,... . So are stream-types having the swapping
-feature now copyable with the swap
-feature -> If so, how do the language-developers achieved it?