17 template <
class Char>
class formatbuf :
public std::basic_streambuf<Char> {
20 using traits_type =
typename std::basic_streambuf<Char>::traits_type;
36 if (!traits_type::eq_int_type(ch, traits_type::eof()))
42 buffer_.
append(s, s + count);
47 template <
typename Char>
struct test_stream : std::basic_ostream<Char> {
53 template <typename T, FMT_ENABLE_IF(std::is_convertible<T, int>::value &&
54 !std::is_enum<T>::value)>
64 << std::declval<U>()),
68 template <
typename>
static std::false_type test(...);
73 static const bool value = result::value;
77 template <
typename Char>
79 const Char* buf_data = buf.
data();
81 unsigned_streamsize size = buf.
size();
82 unsigned_streamsize max_size =
to_unsigned(max_value<std::streamsize>());
84 unsigned_streamsize n = size <= max_size ? size : max_size;
85 os.write(buf_data, static_cast<std::streamsize>(n));
91 template <
typename Char,
typename T>
95 std::basic_ostream<Char> output(&format_buf);
96 if (loc) output.imbue(loc.get<std::locale>());
97 output.exceptions(std::ios_base::failbit | std::ios_base::badbit);
103 template <
typename T,
typename Char>
105 :
formatter<basic_string_view<Char>, Char> {
106 template <
typename Context>
107 auto format(
const T& value, Context& ctx) -> decltype(ctx.out()) {
116 template <
typename Char>
133 template <
typename S,
typename... Args,
135 void print(std::basic_ostream<Char>& os,
const S& format_str, Args&&... args) {
141 #endif // FMT_OSTREAM_H_ #define FMT_BEGIN_NAMESPACE
std::basic_string< Char > format(const text_style &ts, const S &format_str, const Args &... args)
std::size_t size() const FMT_NOEXCEPT
typename internal::void_t_impl< Ts... >::type void_t
decltype(test< T >(0)) result
void print(std::basic_ostream< Char > &os, const S &format_str, Args &&... args)
void append(const U *begin, const U *end)
void vformat_to(basic_memory_buffer< Char > &buf, const text_style &ts, basic_string_view< Char > format_str, basic_format_args< buffer_context< Char >> args)
typename internal::char_t_impl< S >::type char_t
void vprint(std::basic_ostream< Char > &os, basic_string_view< Char > format_str, basic_format_args< buffer_context< Char >> args)
void format_value(buffer< Char > &buf, const T &value, locale_ref loc=locale_ref())
#define FMT_END_NAMESPACE
std::ostream & operator<<(std::ostream &s, const VectorBase< R > &vec)
Output operator.
typename std::enable_if< B, T >::type enable_if_t
std::integral_constant< bool, B > bool_constant
format_arg_store< buffer_context< Char >, remove_reference_t< Args >... > make_args_checked(const S &format_str, const remove_reference_t< Args > &... args)
void push_back(const T &value)
void resize(std::size_t new_size)
void write(std::basic_ostream< Char > &os, buffer< Char > &buf)
FMT_CONSTEXPR std::make_unsigned< Int >::type to_unsigned(Int value)