Why does this code not compile?
#include <sstream>
void f(std::stringstream) { }
int main() {
f(std::stringstream{});
}
I get this error:
error: use of deleted function ‘std::basic_stringstream<char>::basic_stringstream(const std::basic_stringstream<char>&)’
f(std::stringstream{});
^
If I replace std::stringstream
with another type that's noncopyable it works fine. Shouldn't this use stringstream
's move constructor?