[llvm] [Support] add move operators to raw_ostream (PR #85134)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 13 14:34:36 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-support
Author: Sabianin Maksim (s-mx)
<details>
<summary>Changes</summary>
Copy constructor/operator= were explicitly deleted. Hence, move constructor/operator= were left implicitly deleted. This patch declares them by default and allows the following code to be compiled.
raw_fd_ostream openStream(StringRef Path) {
std::error_code EC;
raw_fd_ostream OS(Path, EC);
// handle errors here
return std::move(OS);
}
---
Full diff: https://github.com/llvm/llvm-project/pull/85134.diff
1 Files Affected:
- (modified) llvm/include/llvm/Support/raw_ostream.h (+2)
``````````diff
diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h
index 696290a5d99cf5..de6d6f1e0b006c 100644
--- a/llvm/include/llvm/Support/raw_ostream.h
+++ b/llvm/include/llvm/Support/raw_ostream.h
@@ -143,6 +143,8 @@ class raw_ostream {
raw_ostream(const raw_ostream &) = delete;
void operator=(const raw_ostream &) = delete;
+ raw_ostream(raw_ostream &&) = default;
+ raw_ostream &operator=(raw_ostream &&) = default;
virtual ~raw_ostream();
``````````
</details>
https://github.com/llvm/llvm-project/pull/85134
More information about the llvm-commits
mailing list