gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:28:52 26 4
gpt4 key购买 nike

我正在尝试使用 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

根据 this reference它应该工作。使用不同的 -std 标志(gnu++11、c++0x 等)没有帮助。我错过了什么?

最佳答案

从GCC实现状态看:

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

  • 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.

更多信息 here

关于C++ 编译器无法识别 std::stringstream::swap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24429441/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com