Fix: fmt::ostream cannot be moved while holding buffered data #2197 (#2198)

* Add a test case: move ostream while holding data

* Fix moving ostream while holding data

Co-authored-by: Junliang HU <jlhu@cse.cuhk.edu.hk>
This commit is contained in:
vtta
2021-03-30 08:43:26 -07:00
committed by GitHub
co-authored by Junliang HU
parent 7d8c34018e
commit 14848875bf
2 changed files with 15 additions and 0 deletions
+2
View File
@@ -396,8 +396,10 @@ class ostream final : private detail::buffer<char> {
ostream(ostream&& other)
: detail::buffer<char>(other.data(), other.size(), other.capacity()),
file_(std::move(other.file_)) {
other.clear();
other.set(nullptr, 0);
}
~ostream() {
flush();
delete[] data();