C ++编译器不能识别std :: stringstream :: swap [英] C++ compiler does not recognize std::stringstream::swap

查看:601
本文介绍了C ++编译器不能识别std :: stringstream :: swap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用g ++(GCC)编译以下代码4.8.2 20131212(Red Hat 4.8.2-7):

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);
}

我收到以下错误:

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等)没有帮助。

According to this reference it should work. Using different -std flags (gnu++11, c++0x etc.) didn't help. What am I missing?

推荐答案

从GCC实施状态:


部分:27.5

描述:Iostreams基类

strong>:部分

评论

Section: 27.5
Description: Iostreams base classes
Support: Partial
Comments:


  • 缺少 basic_ios 上移动交换
  • 缺少 io_errc iostream_category

  • ios_base :: failure 不是从 system_error 派生的。

  • 缺少 ios_base :: hexfloat

  • Missing move and swap operations on basic_ios.
  • Missing io_errc and iostream_category.
  • ios_base::failure is not derived from system_error.
  • Missing ios_base::hexfloat.

更多资讯此处

这篇关于C ++编译器不能识别std :: stringstream :: swap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆