mirror of
https://github.com/fmtlib/fmt.git
synced 2025-04-07 10:20:58 +00:00
Fix move constructor (#1844)
This commit is contained in:
parent
69902c1787
commit
6cccdc24bc
@ -396,7 +396,9 @@ class ostream : private detail::buffer<char> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ostream(ostream&& other) : file_(std::move(other.file_)) {
|
ostream(ostream&& other)
|
||||||
|
: detail::buffer<char>(other.data(), other.size(), other.capacity()),
|
||||||
|
file_(std::move(other.file_)) {
|
||||||
other.set(nullptr, 0);
|
other.set(nullptr, 0);
|
||||||
}
|
}
|
||||||
~ostream() {
|
~ostream() {
|
||||||
|
@ -287,6 +287,12 @@ TEST(BufferedFileTest, Fileno) {
|
|||||||
EXPECT_READ(copy, FILE_CONTENT);
|
EXPECT_READ(copy, FILE_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(OStreamTest, Move) {
|
||||||
|
fmt::ostream out = fmt::output_file("test-file");
|
||||||
|
fmt::ostream moved(std::move(out));
|
||||||
|
moved.print("hello");
|
||||||
|
}
|
||||||
|
|
||||||
TEST(OStreamTest, Print) {
|
TEST(OStreamTest, Print) {
|
||||||
fmt::ostream out = fmt::output_file("test-file");
|
fmt::ostream out = fmt::output_file("test-file");
|
||||||
out.print("The answer is {}.\n", 42);
|
out.print("The answer is {}.\n", 42);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user