The copy assignment operator/copy constructor are deleted. However, you can use the member function swap
(C++11), or std::swap
, to swap the content. Or, you can use the move assignment operator (C++11) to move one into the other. This solution works only in the case when you don't care about the content of the source stringstream.
Example:
out = std::move(in); // C++11
out.swap(in); // C++11
std::swap(out, in);
PS: I just realized that g++ does not compile any of the above lines (it seems it doesn't support move/swap for ostringstream), however, clang++ compiles it. According to the standard (27.8.4), swap/move should work.
See C++ compiler does not recognize std::stringstream::swap