Dvir Yitzchaki via llvm-dev
2017-Jul-11 12:31 UTC
[llvm-dev] returning Expected<tool_output_file>
Hi list. I've wrote a function which creates an output file as follows: llvm::Expected<llvm::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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170711/6ae28161/attachment.html>
Dvir Yitzchaki via llvm-dev
2017-Jul-12 09:25 UTC
[llvm-dev] returning Expected<tool_output_file>
Actually, a default move constructor is not good as it needs to swap the buffers, so I have to define it myself. Regards, Dvir From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of Dvir Yitzchaki via llvm-dev Sent: Tuesday, July 11, 2017 15:31 To: llvm-dev at lists.llvm.org Subject: [llvm-dev] returning Expected<tool_output_file> Hi list. I've wrote a function which creates an output file as follows: llvm::Expected<llvm::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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170712/676688fa/attachment.html>