4

我正在尝试使用 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 等)没有帮助。我错过了什么?

4

1 回答 1

7

从 GCC 实施情况来看:

部分:27.5
描述:Iostreams 基类
支持:部分
评论

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

更多信息在这里

于 2014-06-26T11:45:06.187 回答