Remove printf.h dependency on ostream.h

This commit is contained in:
Victor Zverovich 2021-04-23 10:42:57 -07:00
parent c47f211296
commit b9ab5c8836
2 changed files with 6 additions and 5 deletions

View File

@ -10,8 +10,9 @@
#include <algorithm> // std::max #include <algorithm> // std::max
#include <limits> // std::numeric_limits #include <limits> // std::numeric_limits
#include <ostream>
#include "ostream.h" #include "format.h"
FMT_BEGIN_NAMESPACE FMT_BEGIN_NAMESPACE
namespace detail { namespace detail {
@ -194,7 +195,7 @@ FMT_DEPRECATED void printf(detail::buffer<Char>& buf,
} }
using detail::vprintf; using detail::vprintf;
// already exported through "ostream.h" above // Exported from ostream.h.
template <typename Char> template <typename Char>
class basic_printf_parse_context : public basic_format_parse_context<Char> { class basic_printf_parse_context : public basic_format_parse_context<Char> {
using basic_format_parse_context<Char>::basic_format_parse_context; using basic_format_parse_context<Char>::basic_format_parse_context;
@ -290,8 +291,7 @@ template <typename T> struct printf_formatter {
} }
template <typename FormatContext> template <typename FormatContext>
auto format(const T& value, FormatContext& ctx) -> decltype(ctx.out()) { auto format(const T&, FormatContext& ctx) -> decltype(ctx.out()) {
detail::format_value(detail::get_container(ctx.out()), value);
return ctx.out(); return ctx.out();
} }
}; };
@ -688,7 +688,7 @@ inline int vfprintf(
basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) { basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) {
basic_memory_buffer<Char> buffer; basic_memory_buffer<Char> buffer;
vprintf(buffer, to_string_view(format), args); vprintf(buffer, to_string_view(format), args);
detail::write_buffer(os, buffer); os.write(buffer.data(), static_cast<std::streamsize>(buffer.size()));
return static_cast<int>(buffer.size()); return static_cast<int>(buffer.size());
} }

View File

@ -12,6 +12,7 @@
#include <cstring> #include <cstring>
#include "fmt/core.h" #include "fmt/core.h"
#include "fmt/ostream.h"
#include "gtest-extra.h" #include "gtest-extra.h"
#include "util.h" #include "util.h"