attempt to make the compiler happy

This commit is contained in:
Ihor Dutchak 2022-10-14 12:30:48 +03:00
parent e75f9b8e38
commit 4e0c8667d3

View File

@ -379,7 +379,7 @@ struct ostream_params {
# endif # endif
}; };
class ostream_buffer final : public detail::buffer<char> { template <typename Char> class file_buffer final : public detail::buffer<Char> {
file file_; file file_;
void grow(size_t) override { void grow(size_t) override {
@ -387,25 +387,27 @@ class ostream_buffer final : public detail::buffer<char> {
} }
public: public:
ostream_buffer(cstring_view path, const detail::ostream_params& params) file_buffer(cstring_view path, const detail::ostream_params& params)
: file_(path, params.oflag) { : file_(path, params.oflag) {
set(new char[params.buffer_size], params.buffer_size); detail::buffer<Char>::set(new Char[params.buffer_size], params.buffer_size);
} }
ostream_buffer(ostream_buffer&& other) file_buffer(file_buffer&& other)
: detail::buffer<char>(other.data(), other.size(), other.capacity()), : detail::buffer<Char>(other.data(), other.size(), other.capacity()),
file_(std::move(other.file_)) { file_(std::move(other.file_)) {
other.clear(); other.clear();
other.set(nullptr, 0); other.set(nullptr, 0);
} }
~ostream_buffer() { ~file_buffer() {
flush(); flush();
delete[] data(); delete[] detail::buffer<Char>::data();
} }
void flush() { void flush() {
if (size() == 0) return; if (detail::buffer<Char>::size() == 0) return;
file_.write(data(), size()); file_.write(
clear(); detail::buffer<Char>::data(),
detail::buffer<Char>::size() * sizeof(detail::buffer<Char>::data()[0]));
detail::buffer<Char>::clear();
} }
void close() { void close() {
@ -424,7 +426,7 @@ constexpr detail::buffer_size buffer_size{};
class FMT_API ostream final { class FMT_API ostream final {
private: private:
FMT_MSC_WARNING(suppress : 4251) FMT_MSC_WARNING(suppress : 4251)
detail::ostream_buffer buffer_; detail::file_buffer<char> buffer_;
ostream(cstring_view path, const detail::ostream_params& params) ostream(cstring_view path, const detail::ostream_params& params)
: buffer_(path, params) {} : buffer_(path, params) {}