[英]Std::stringstream move assignment not working in gcc
An assignment like the following 像下面这样的作业
std::stringstream strstr;
strstr = std::stringstream(someString)
does give me an error when compiling in gcc: 在gcc中编译时确实给我一个错误:
error: use of deleted function ‘std::basic_stringstream<char>& std::basic_stringstream<char>::operator=(const std::basic_stringstream<char>&)’
Now, I know that streams apparently cannot be copied and the copy constructor of std::stringstream
is marked as deleted. 现在,我知道流显然无法复制,并且std::stringstream
的副本构造函数被标记为已删除。 However, to my understanding the aforementioned should be a move assignment, not a copy assignment since there is an r-value on the right side of the assignment operator. 但是,据我所知,上述内容应该是移动分配,而不是副本分配,因为在赋值运算符的右侧有一个r值。
Althogh in this case it could probably solve by just using strstr.str(someString)
instead, I still would be interested in what causes this compiler error. 在这种情况下,仅通过使用strstr.str(someString)
即可解决问题,我仍然会对引起此编译器错误的原因感兴趣。 It compiles without problems in VC++ by the way. 顺便说一下,它在VC ++中编译没有问题。
This was delayed for reasons of ABI compatibilty. 由于ABI兼容性,此操作被延迟。 They wanted to wait for a major version number change. 他们想等待主要版本号更改。 It is there in the recently released version 5.1: https://gcc.gnu.org/gcc-5/changes.html#libstdcxx 在最新发布的5.1版中可以找到它: https : //gcc.gnu.org/gcc-5/changes.html#libstdcxx
- movable and swappable iostream classes; 可移动和可交换的iostream类;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.