C++编译器无法识别std :: stringstream :: swap

pet*_*eti 4 c++ c++11 g++4.8

我试图用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);
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

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
Run Code Online (Sandbox Code Playgroud)

根据这个参考,它应该工作.使用不同的-std标志(gnu ++ 11,c ++ 0x等)没有帮助.我错过了什么?

小智 7

从GCC实施状态:

部分:27.5
描述:Iostreams基类
支持:部分
注释:

  • 缺少moveswap操作basic_ios.
  • 失踪io_errciostream_category.
  • ios_base::failure不是源于system_error.
  • 失踪ios_base::hexfloat.

更多信息在这里