简体   繁体   中英

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:

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

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. It compiles without problems in VC++ by the way.

This was delayed for reasons of ABI compatibilty. 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

  • movable and swappable iostream classes;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM