在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::trying流时所收到的错误是:
158:错误:使用已删除的函数'std::basic_stringstream& std::basic_stringstream::operator=(const std::basic_stringstream&)‘流=std::str stream (Str);^
发布于 2015-06-25 16:04:50
std::stringstream
是不可复制的,但只能被移动(因为C++11)。我猜您使用的是g++4.9或更早的版本,即使它支持C++11,它也不完全支持流的移动语义。g++5及以后编译您的代码。
报告的bug可以追溯到4.7,修正在5.x bug.cgi?id=54316中。
https://stackoverflow.com/questions/31062733
复制相似问题