I am trying to compile the following code with g++ (GCC) 4.8.2 20131212 (Red Hat 4.8.2-7):
#include <sstream>
using namespace std;
int main(int argc, char ** argv)
{
auto x = 1;
stringstream s1, s2;
s1.swap(s2);
}
I get the following error:
g++ -g -std=c++0x -c main.cpp
main.cpp: In function ‘int main(int, char**)’:
main.cpp:8:5: error: ‘std::stringstream’ has no member named ‘swap’
s1.swap(s2);
^
make: *** [main.o] Error 1
According to this reference it should work. Using different -std flags (gnu++11, c++0x etc.) didn't help. What am I missing?