returning Expected<tool_output_file>

Hi list.

I’ve wrote a function which creates an output file as follows:

llvm::Expectedllvm::tool_output_file

createOutputFile(llvm::StringRef FileName) {

std::error_code EC;

llvm::tool_output_file Out(FileName, EC, llvm::sys::fs::F_Text);

if (EC) {

return llvm::errorCodeToError(EC);

}

return Out;

}

This fails to compile, however because tool_output_file is not copyable or even moveable which Expected requires.

If I add default move constructors to raw_ostream and raw_fd_ostream the code above compile fine.

Is such a patch welcome? Is there a different way to achieve this?

Regards,

Dvir

Actually, a default move constructor is not good as it needs to swap the buffers, so I have to define it myself.

Regards,

Dvir