std::stringstream推理在Visual Studio 2013上有效,但在Linux下无效
std::stringstream reasignment works on Visual Studio 2013 but not under Linux
在Windows上获得完美成功后,我正试图在Linux上编译以下代码:
std::string str = stream.str();
auto decrement = [](char c) { return c - 100; };
std::transform(str.begin(), str.end(), str.begin(), decrement);
stream = std::stringstream(str); // LINE ACCUSING ERROR
我在尝试重新设计std::字符串流时收到的错误是:
158:错误:使用已删除的函数"std::basic_stringstream&std::basic_stringstream::operator=(conststd::basic_stringstream&)'stream=std::字符串流(str);^
std::stringstream
不可复制,但只能移动(因为C++11)。我的猜测是,您使用g++4.9或更早版本,即使它支持C++11,它也不能完全支持流的移动语义。g++5,并在以后编译您的代码。
报告的错误可追溯到4.7,在5.x中修复https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54316
相关文章:
- 点云库在VS 2019中不起作用,但在VS 2017中确实有效
- 为什么以下代码在在线 ide(gcc 7.2.0) 上有效,但在 ubuntu 上出现错误?
- 类外的前向声明有效,但在嵌套时无效
- 将指针传递给函数在简单的情况下有效,但在"class" -izing 之后不起作用
- 为什么这段代码在Visual Studio中有效,但在gcc中失败
- 程序在C++ Tutor中执行时有效,但在其他任何地方都不起作用
- 程序有效,但在 20-30 秒后随机关闭
- 作为模板非类型参数的 C 字符串在 gcc 6.3 中有效,但在 Visual Studio 2017(x64 为 19
- 将流定义为私有类变量似乎在Linux下有效,但在WindowsVisualStudio下无效
- 在C++中嵌入Python:在Python脚本中导入模块在一个函数调用过程中有效,但在另一个调用过程中无效
- 为什么这个取消注释的宏在 clang 中无效,但在 msvc 中有效
- Tensorflow模型在Python中有效,但在C++中无效
- 为什么这个逻辑在我的主循环上有效,但在方法上不起作用
- C++代码在 Gedit 中有效,但在 VS 中不起作用(它只是打印"按任意键退出......"。消息)
- Exe不是有效的win32应用程序,但在64位上运行
- glGenVertexArrays在主循环中不创建唯一的VAO,但在其他情况下有效
- 为什么 decltype 在这里有效但不能自动?
- 为什么将boost::move()的返回值分配给非常数引用在C++0x模式下失败,但在C++03模式下有效
- 分段错误(核心转储) - 代码在 VS 中有效,但在 Linux 终端中不起作用
- 为什么从字符串常量到"char*"的转换在 C 中有效,但在C++中无效