uk4*_*321 4 c++ rvalue move-semantics c++11
为什么这段代码不能编译?
#include <sstream>
void f(std::stringstream) { }
int main() {
f(std::stringstream{});
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
error: use of deleted function ‘std::basic_stringstream<char>::basic_stringstream(const std::basic_stringstream<char>&)’
f(std::stringstream{});
^
Run Code Online (Sandbox Code Playgroud)
如果我std::stringstream用另一种不可复制的类型替换它可以正常工作.不应该使用stringstream移动构造函数吗?