template <class charT, class traits, class Alloc> void swap (basic_stringstream<charT,traits,Alloc>& x, basic_stringstream<charT,traits,Alloc>& y);
12345678910111213141516171819202122
// swapping stringstream objects #include <string> // std::string #include <iostream> // std::cout #include <sstream> // std::stringstream int main () { std::stringstream foo; std::stringstream bar; foo << 100; bar << 200; swap(foo,bar); int val; foo >> val; std::cout << "foo: " << val << '\n'; bar >> val; std::cout << "bar: " << val << '\n'; return 0; }
foo: 200 bar: 100