Why can't std::ostream be moved?
问题 Clearly, streams can\'t be copied. It should be possible to move streams. According to 27.9.1.11 [ofstream.cons] paragraph 4 it is possible to move construct an std::ofstream (the same is true for std::ifstream , std::fstream , and the std::*stringstream variants). For example: #include <iostream> #include <fstream> #include <string> std::ofstream makeStream(std::string const& name) { return std::ofstream(name); } int main() { std::ofstream out{ makeStream(\"example.log\") }; } Trying to move