我正在尝试使用 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);
}
我收到以下错误:
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
根据这个参考它应该工作。使用不同的 -std 标志(gnu++11、c++0x 等)没有帮助。我错过了什么?