FMT_CHAR -> char_t

This commit is contained in:
Victor Zverovich
2019-06-01 12:32:24 -07:00
parent 56d2b91108
commit 4d4b8c238d
7 changed files with 99 additions and 94 deletions

View File

@ -556,7 +556,7 @@ std::basic_string<Char> vformat(
} }
} // namespace internal } // namespace internal
template <typename S, typename Char = typename internal::char_t<S>::type> template <typename S, typename Char = char_t<S> >
void vprint(std::FILE* f, const text_style& ts, const S& format, void vprint(std::FILE* f, const text_style& ts, const S& format,
basic_format_args<typename buffer_context<Char>::type> args) { basic_format_args<typename buffer_context<Char>::type> args) {
bool has_style = false; bool has_style = false;
@ -587,13 +587,12 @@ void vprint(std::FILE* f, const text_style& ts, const S& format,
fmt::print(fmt::emphasis::bold | fg(fmt::color::red), fmt::print(fmt::emphasis::bold | fg(fmt::color::red),
"Elapsed time: {0:.2f} seconds", 1.23); "Elapsed time: {0:.2f} seconds", 1.23);
*/ */
template <typename String, typename... Args, template <typename S, typename... Args,
FMT_ENABLE_IF(internal::is_string<String>::value)> FMT_ENABLE_IF(internal::is_string<S>::value)>
void print(std::FILE* f, const text_style& ts, const String& format_str, void print(std::FILE* f, const text_style& ts, const S& format_str,
const Args&... args) { const Args&... args) {
internal::check_format_string<Args...>(format_str); internal::check_format_string<Args...>(format_str);
typedef typename internal::char_t<String>::type char_t; typedef typename buffer_context<char_t<S> >::type context_t;
typedef typename buffer_context<char_t>::type context_t;
format_arg_store<context_t, Args...> as{args...}; format_arg_store<context_t, Args...> as{args...};
vprint(f, ts, format_str, basic_format_args<context_t>(as)); vprint(f, ts, format_str, basic_format_args<context_t>(as));
} }
@ -605,14 +604,13 @@ void print(std::FILE* f, const text_style& ts, const String& format_str,
fmt::print(fmt::emphasis::bold | fg(fmt::color::red), fmt::print(fmt::emphasis::bold | fg(fmt::color::red),
"Elapsed time: {0:.2f} seconds", 1.23); "Elapsed time: {0:.2f} seconds", 1.23);
*/ */
template <typename String, typename... Args, template <typename S, typename... Args,
FMT_ENABLE_IF(internal::is_string<String>::value)> FMT_ENABLE_IF(internal::is_string<S>::value)>
void print(const text_style& ts, const String& format_str, void print(const text_style& ts, const S& format_str, const Args&... args) {
const Args&... args) {
return print(stdout, ts, format_str, args...); return print(stdout, ts, format_str, args...);
} }
template <typename S, typename Char = FMT_CHAR(S)> template <typename S, typename Char = char_t<S> >
inline std::basic_string<Char> vformat( inline std::basic_string<Char> vformat(
const text_style& ts, const S& format_str, const text_style& ts, const S& format_str,
basic_format_args<typename buffer_context<Char>::type> args) { basic_format_args<typename buffer_context<Char>::type> args) {
@ -631,10 +629,9 @@ inline std::basic_string<Char> vformat(
"The answer is {}", 42); "The answer is {}", 42);
\endrst \endrst
*/ */
template <typename S, typename... Args> template <typename S, typename... Args, typename Char = char_t<S> >
inline std::basic_string<FMT_CHAR(S)> format(const text_style& ts, inline std::basic_string<Char> format(const text_style& ts, const S& format_str,
const S& format_str, const Args&... args) {
const Args&... args) {
return internal::vformat(ts, to_string_view(format_str), return internal::vformat(ts, to_string_view(format_str),
{internal::make_args_checked(format_str, args...)}); {internal::make_args_checked(format_str, args...)});
} }

View File

@ -617,7 +617,7 @@ struct is_string
template <> struct is_string<std::FILE*>; template <> struct is_string<std::FILE*>;
template <> struct is_string<const std::FILE*>; template <> struct is_string<const std::FILE*>;
template <typename S> struct char_t { template <typename S> struct char_t_impl {
typedef decltype(to_string_view(std::declval<S>())) result; typedef decltype(to_string_view(std::declval<S>())) result;
typedef typename result::char_type type; typedef typename result::char_type type;
}; };
@ -883,7 +883,7 @@ FMT_CONSTEXPR11 init<C, basic_string_view<typename C::char_type>, string_type>
make_value(const S& val) { make_value(const S& val) {
// Handle adapted strings. // Handle adapted strings.
static_assert(std::is_same<typename C::char_type, static_assert(std::is_same<typename C::char_type,
typename internal::char_t<S>::type>::value, typename internal::char_t_impl<S>::type>::value,
"mismatch between char-types of context and argument"); "mismatch between char-types of context and argument");
return to_string_view(val); return to_string_view(val);
} }
@ -1311,8 +1311,7 @@ struct wformat_args : basic_format_args<wformat_context> {
}; };
/** String's character type. */ /** String's character type. */
template <typename S> using char_t = typename internal::char_t<S>::type; template <typename S> using char_t = typename internal::char_t_impl<S>::type;
#define FMT_CHAR(S) fmt::char_t<S>
namespace internal { namespace internal {
template <typename Context> template <typename Context>
@ -1353,8 +1352,8 @@ template <typename... Args, typename S,
void check_format_string(S); void check_format_string(S);
template <typename S, typename... Args, template <typename S, typename... Args,
FMT_ENABLE_IF(internal::is_string<S>::value)> typename Char = enable_if_t<internal::is_string<S>::value, char_t<S>>>
inline format_arg_store<typename buffer_context<FMT_CHAR(S)>::type, Args...> inline format_arg_store<typename buffer_context<Char>::type, Args...>
make_args_checked(const S& format_str, const Args&... args) { make_args_checked(const S& format_str, const Args&... args) {
internal::check_format_string<Args...>(format_str); internal::check_format_string<Args...>(format_str);
return {args...}; return {args...};
@ -1386,8 +1385,8 @@ typename buffer_context<Char>::type::iterator vformat_to(
fmt::print("Elapsed time: {s:.2f} seconds", fmt::arg("s", 1.23)); fmt::print("Elapsed time: {s:.2f} seconds", fmt::arg("s", 1.23));
\endrst \endrst
*/ */
template <typename S, typename T> template <typename S, typename T, typename Char = char_t<S>>
inline internal::named_arg<T, FMT_CHAR(S)> arg(const S& name, const T& arg) { inline internal::named_arg<T, Char> arg(const S& name, const T& arg) {
static_assert(internal::is_string<S>::value, ""); static_assert(internal::is_string<S>::value, "");
return {name, arg}; return {name, arg};
} }
@ -1404,13 +1403,23 @@ struct is_contiguous<std::basic_string<Char>> : std::true_type {};
template <typename Char> template <typename Char>
struct is_contiguous<internal::buffer<Char>> : std::true_type {}; struct is_contiguous<internal::buffer<Char>> : std::true_type {};
template <typename OutputIt>
struct is_contiguous_back_insert_iterator : std::false_type {};
template <typename Container>
struct is_contiguous_back_insert_iterator<std::back_insert_iterator<Container>>
: is_contiguous<Container> {};
/** Formats a string and writes the output to ``out``. */ /** Formats a string and writes the output to ``out``. */
template <typename Container, typename S> template <typename OutputIt, typename S,
typename std::enable_if<is_contiguous<Container>::value, typename Char = enable_if_t<
std::back_insert_iterator<Container>>::type is_contiguous_back_insert_iterator<OutputIt>::value, char_t<S>>>
vformat_to(std::back_insert_iterator<Container> out, const S& format_str, OutputIt vformat_to(
basic_format_args<typename buffer_context<FMT_CHAR(S)>::type> args) { OutputIt out, const S& format_str,
internal::container_buffer<Container> buf(internal::get_container(out)); basic_format_args<typename buffer_context<Char>::type> args) {
using container = typename std::remove_reference<decltype(
internal::get_container(out))>::type;
internal::container_buffer<container> buf((internal::get_container(out)));
internal::vformat_to(buf, to_string_view(format_str), args); internal::vformat_to(buf, to_string_view(format_str), args);
return out; return out;
} }
@ -1425,8 +1434,8 @@ inline std::back_insert_iterator<Container> format_to(
{internal::make_args_checked(format_str, args...)}); {internal::make_args_checked(format_str, args...)});
} }
template <typename S, typename Char = FMT_CHAR(S), template <typename S,
FMT_ENABLE_IF(internal::is_string<S>::value)> typename Char = enable_if_t<internal::is_string<S>::value, char_t<S>>>
inline std::basic_string<Char> vformat( inline std::basic_string<Char> vformat(
const S& format_str, const S& format_str,
basic_format_args<typename buffer_context<Char>::type> args) { basic_format_args<typename buffer_context<Char>::type> args) {
@ -1443,11 +1452,12 @@ inline std::basic_string<Char> vformat(
std::string message = fmt::format("The answer is {}", 42); std::string message = fmt::format("The answer is {}", 42);
\endrst \endrst
*/ */
// Pass fmt::char_t as a default template parameter instead of using // Pass char_t as a default template parameter instead of using
// std::basic_string<fmt::char_t<S>> to reduce the symbol size. // std::basic_string<char_t<S>> to reduce the symbol size.
template <typename S, typename... Args, template <typename S, typename... Args,
typename Char = enable_if_t<internal::is_string<S>::value, char_t<S>>> typename Char = enable_if_t<internal::is_string<S>::value, char_t<S>>>
inline std::basic_string<Char> format(const S& format_str, const Args&... args) { inline std::basic_string<Char> format(const S& format_str,
const Args&... args) {
return internal::vformat(to_string_view(format_str), return internal::vformat(to_string_view(format_str),
{internal::make_args_checked(format_str, args...)}); {internal::make_args_checked(format_str, args...)});
} }

View File

@ -1805,10 +1805,11 @@ struct string_view_metadata {
: offset_(view.data() - primary_string.data()), size_(view.size()) {} : offset_(view.data() - primary_string.data()), size_(view.size()) {}
FMT_CONSTEXPR string_view_metadata(std::size_t offset, std::size_t size) FMT_CONSTEXPR string_view_metadata(std::size_t offset, std::size_t size)
: offset_(offset), size_(size) {} : offset_(offset), size_(size) {}
template <typename S, FMT_ENABLE_IF(internal::is_string<S>::value)> template <typename S, typename Char = enable_if_t<
FMT_CONSTEXPR basic_string_view<FMT_CHAR(S)> to_view(S&& str) const { internal::is_string<S>::value, char_t<S>>>
FMT_CONSTEXPR basic_string_view<Char> to_view(S&& str) const {
const auto view = to_string_view(str); const auto view = to_string_view(str);
return basic_string_view<FMT_CHAR(S)>(view.data() + offset_, size_); return basic_string_view<Char>(view.data() + offset_, size_);
} }
std::size_t offset_; std::size_t offset_;
@ -3384,7 +3385,7 @@ typename buffer_context<Char>::type::iterator internal::vformat_to(
args); args);
} }
template <typename S, typename Char = FMT_CHAR(S), template <typename S, typename Char = char_t<S>,
FMT_ENABLE_IF(internal::is_string<S>::value)> FMT_ENABLE_IF(internal::is_string<S>::value)>
inline typename buffer_context<Char>::type::iterator vformat_to( inline typename buffer_context<Char>::type::iterator vformat_to(
internal::buffer<Char>& buf, const S& format_str, internal::buffer<Char>& buf, const S& format_str,
@ -3393,12 +3394,12 @@ inline typename buffer_context<Char>::type::iterator vformat_to(
} }
template <typename S, typename... Args, std::size_t SIZE = inline_buffer_size, template <typename S, typename... Args, std::size_t SIZE = inline_buffer_size,
typename Char = typename internal::char_t<S>::type> typename Char = enable_if_t<internal::is_string<S>::value, char_t<S>>>
inline typename buffer_context<Char>::type::iterator format_to( inline typename buffer_context<Char>::type::iterator format_to(
basic_memory_buffer<Char, SIZE>& buf, const S& format_str, basic_memory_buffer<Char, SIZE>& buf, const S& format_str,
const Args&... args) { const Args&... args) {
internal::check_format_string<Args...>(format_str); internal::check_format_string<Args...>(format_str);
typedef typename buffer_context<Char>::type context; using context = typename buffer_context<Char>::type;
format_arg_store<context, Args...> as{args...}; format_arg_store<context, Args...> as{args...};
return internal::vformat_to(buf, to_string_view(format_str), return internal::vformat_to(buf, to_string_view(format_str),
basic_format_args<context>(as)); basic_format_args<context>(as));
@ -3459,12 +3460,13 @@ struct format_args_t {
type; type;
}; };
template <typename String, typename OutputIt, typename... Args, template <typename S, typename OutputIt, typename... Args,
FMT_ENABLE_IF(internal::is_output_iterator<OutputIt>::value)> FMT_ENABLE_IF(internal::is_output_iterator<OutputIt>::value &&
!is_contiguous_back_insert_iterator<OutputIt>::value)>
inline OutputIt vformat_to( inline OutputIt vformat_to(
OutputIt out, const String& format_str, OutputIt out, const S& format_str,
typename format_args_t<OutputIt, FMT_CHAR(String)>::type args) { typename format_args_t<OutputIt, char_t<S>>::type args) {
typedef output_range<OutputIt, FMT_CHAR(String)> range; typedef output_range<OutputIt, char_t<S>> range;
return vformat_to<arg_formatter<range>>(range(out), return vformat_to<arg_formatter<range>>(range(out),
to_string_view(format_str), args); to_string_view(format_str), args);
} }
@ -3481,13 +3483,13 @@ inline OutputIt vformat_to(
\endrst \endrst
*/ */
template <typename OutputIt, typename S, typename... Args> template <typename OutputIt, typename S, typename... Args>
inline inline OutputIt format_to(OutputIt out, const S& format_str,
typename std::enable_if<internal::is_string<S>::value && const Args&... args) {
internal::is_output_iterator<OutputIt>::value, static_assert(internal::is_output_iterator<OutputIt>::value &&
OutputIt>::type internal::is_string<S>::value,
format_to(OutputIt out, const S& format_str, const Args&... args) { "");
internal::check_format_string<Args...>(format_str); internal::check_format_string<Args...>(format_str);
typedef typename format_context_t<OutputIt, FMT_CHAR(S)>::type context; typedef typename format_context_t<OutputIt, char_t<S>>::type context;
format_arg_store<context, Args...> as{args...}; format_arg_store<context, Args...> as{args...};
return vformat_to(out, to_string_view(format_str), return vformat_to(out, to_string_view(format_str),
basic_format_args<context>(as)); basic_format_args<context>(as));
@ -3542,7 +3544,7 @@ inline format_to_n_result<OutputIt> format_to_n(OutputIt out, std::size_t n,
const S& format_str, const S& format_str,
const Args&... args) { const Args&... args) {
internal::check_format_string<Args...>(format_str); internal::check_format_string<Args...>(format_str);
typedef FMT_CHAR(S) Char; using Char = char_t<S>;
format_arg_store<typename format_to_n_context<OutputIt, Char>::type, Args...> format_arg_store<typename format_to_n_context<OutputIt, Char>::type, Args...>
as(args...); as(args...);
return vformat_to_n(out, n, to_string_view(format_str), return vformat_to_n(out, n, to_string_view(format_str),

View File

@ -34,38 +34,39 @@ std::basic_string<Char> vformat(
} }
} // namespace internal } // namespace internal
template <typename S, typename Char = FMT_CHAR(S)> template <typename S, typename Char = char_t<S>>
inline std::basic_string<Char> vformat( inline std::basic_string<Char> vformat(
const std::locale& loc, const S& format_str, const std::locale& loc, const S& format_str,
basic_format_args<typename buffer_context<Char>::type> args) { basic_format_args<typename buffer_context<Char>::type> args) {
return internal::vformat(loc, to_string_view(format_str), args); return internal::vformat(loc, to_string_view(format_str), args);
} }
template <typename S, typename... Args> template <typename S, typename... Args, typename Char = char_t<S>>
inline std::basic_string<FMT_CHAR(S)> format(const std::locale& loc, inline std::basic_string<Char> format(const std::locale& loc,
const S& format_str, const S& format_str,
const Args&... args) { const Args&... args) {
return internal::vformat(loc, to_string_view(format_str), return internal::vformat(loc, to_string_view(format_str),
{internal::make_args_checked(format_str, args...)}); {internal::make_args_checked(format_str, args...)});
} }
template <typename String, typename OutputIt, typename... Args, template <typename S, typename OutputIt, typename... Args,
FMT_ENABLE_IF(internal::is_output_iterator<OutputIt>::value)> typename Char = enable_if_t<
inline OutputIt vformat_to( internal::is_output_iterator<OutputIt>::value, char_t<S>>>
OutputIt out, const std::locale& loc, const String& format_str, inline OutputIt vformat_to(OutputIt out, const std::locale& loc,
typename format_args_t<OutputIt, FMT_CHAR(String)>::type args) { const S& format_str,
typedef output_range<OutputIt, FMT_CHAR(String)> range; typename format_args_t<OutputIt, Char>::type args) {
using range = output_range<OutputIt, Char>;
return vformat_to<arg_formatter<range>>( return vformat_to<arg_formatter<range>>(
range(out), to_string_view(format_str), args, internal::locale_ref(loc)); range(out), to_string_view(format_str), args, internal::locale_ref(loc));
} }
template <typename OutputIt, typename S, typename... Args, template <typename OutputIt, typename S, typename... Args,
FMT_ENABLE_IF(internal::is_string<S>::value&& FMT_ENABLE_IF(internal::is_output_iterator<OutputIt>::value&&
internal::is_output_iterator<OutputIt>::value)> internal::is_string<S>::value)>
inline OutputIt format_to(OutputIt out, const std::locale& loc, inline OutputIt format_to(OutputIt out, const std::locale& loc,
const S& format_str, const Args&... args) { const S& format_str, const Args&... args) {
internal::check_format_string<Args...>(format_str); internal::check_format_string<Args...>(format_str);
typedef typename format_context_t<OutputIt, FMT_CHAR(S)>::type context; using context = typename format_context_t<OutputIt, char_t<S>>::type;
format_arg_store<context, Args...> as{args...}; format_arg_store<context, Args...> as{args...};
return vformat_to(out, loc, to_string_view(format_str), return vformat_to(out, loc, to_string_view(format_str),
basic_format_args<context>(as)); basic_format_args<context>(as));

View File

@ -120,13 +120,13 @@ struct convert_to_int<
}; };
template <typename Char> template <typename Char>
inline void vprint( void vprint(std::basic_ostream<Char>& os, basic_string_view<Char> format_str,
std::basic_ostream<Char>& os, basic_string_view<Char> format_str, basic_format_args<typename buffer_context<Char>::type> args) {
basic_format_args<typename buffer_context<Char>::type> args) {
basic_memory_buffer<Char> buffer; basic_memory_buffer<Char> buffer;
internal::vformat_to(buffer, format_str, args); internal::vformat_to(buffer, format_str, args);
internal::write(os, buffer); internal::write(os, buffer);
} }
/** /**
\rst \rst
Prints formatted data to the stream *os*. Prints formatted data to the stream *os*.
@ -137,8 +137,8 @@ inline void vprint(
\endrst \endrst
*/ */
template <typename S, typename... Args, template <typename S, typename... Args,
FMT_ENABLE_IF(internal::is_string<S>::value)> typename Char = enable_if_t<internal::is_string<S>::value, char_t<S>>>
inline void print(std::basic_ostream<FMT_CHAR(S)>& os, const S& format_str, inline void print(std::basic_ostream<Char>& os, const S& format_str,
const Args&... args) { const Args&... args) {
vprint(os, to_string_view(format_str), vprint(os, to_string_view(format_str),
{internal::make_args_checked(format_str, args...)}); {internal::make_args_checked(format_str, args...)});

View File

@ -185,8 +185,8 @@ class format_preparation_handler : public internal::error_handler {
template <typename Format, typename PreparedPartsProvider, typename... Args> template <typename Format, typename PreparedPartsProvider, typename... Args>
class prepared_format { class prepared_format {
public: public:
typedef FMT_CHAR(Format) char_type; using char_type = char_t<Format>;
typedef format_part<char_type> format_part_t; using format_part_t = format_part<char_type>;
prepared_format(Format f) prepared_format(Format f)
: format_(std::move(f)), parts_provider_(to_string_view(format_)) {} : format_(std::move(f)), parts_provider_(to_string_view(format_)) {}
@ -351,7 +351,7 @@ class prepared_format {
template <typename Format> class compiletime_prepared_parts_type_provider { template <typename Format> class compiletime_prepared_parts_type_provider {
private: private:
typedef FMT_CHAR(Format) char_type; using char_type = char_t<Format>;
class count_handler { class count_handler {
private: private:
@ -649,7 +649,7 @@ class parts_container {
// Delegate preparing to preparator, to take advantage of a partial // Delegate preparing to preparator, to take advantage of a partial
// specialization. // specialization.
template <typename Format, typename... Args> struct preparator { template <typename Format, typename... Args> struct preparator {
typedef parts_container<FMT_CHAR(Format)> container; typedef parts_container<char_t<Format>> container;
typedef typename basic_prepared_format<Format, container, Args...>::type typedef typename basic_prepared_format<Format, container, Args...>::type
prepared_format_type; prepared_format_type;

View File

@ -608,7 +608,7 @@ inline format_arg_store<wprintf_context, Args...> make_wprintf_args(
return {args...}; return {args...};
} }
template <typename S, typename Char = FMT_CHAR(S)> template <typename S, typename Char = char_t<S>>
inline std::basic_string<Char> vsprintf( inline std::basic_string<Char> vsprintf(
const S& format, const S& format,
basic_format_args< basic_format_args<
@ -629,16 +629,14 @@ inline std::basic_string<Char> vsprintf(
\endrst \endrst
*/ */
template <typename S, typename... Args, template <typename S, typename... Args,
FMT_ENABLE_IF(internal::is_string<S>::value)> typename Char = enable_if_t<internal::is_string<S>::value, char_t<S>>>
inline std::basic_string<FMT_CHAR(S)> sprintf(const S& format, inline std::basic_string<Char> sprintf(const S& format, const Args&... args) {
const Args&... args) { using context = typename basic_printf_context_t<internal::buffer<Char>>::type;
typedef internal::buffer<FMT_CHAR(S)> buffer;
typedef typename basic_printf_context_t<buffer>::type context;
format_arg_store<context, Args...> as{args...}; format_arg_store<context, Args...> as{args...};
return vsprintf(to_string_view(format), basic_format_args<context>(as)); return vsprintf(to_string_view(format), basic_format_args<context>(as));
} }
template <typename S, typename Char = FMT_CHAR(S)> template <typename S, typename Char = char_t<S>>
inline int vfprintf( inline int vfprintf(
std::FILE* f, const S& format, std::FILE* f, const S& format,
basic_format_args< basic_format_args<
@ -662,15 +660,14 @@ inline int vfprintf(
\endrst \endrst
*/ */
template <typename S, typename... Args, template <typename S, typename... Args,
FMT_ENABLE_IF(internal::is_string<S>::value)> typename Char = enable_if_t<internal::is_string<S>::value, char_t<S>>>
inline int fprintf(std::FILE* f, const S& format, const Args&... args) { inline int fprintf(std::FILE* f, const S& format, const Args&... args) {
typedef internal::buffer<FMT_CHAR(S)> buffer; using context = typename basic_printf_context_t<internal::buffer<Char>>::type;
typedef typename basic_printf_context_t<buffer>::type context;
format_arg_store<context, Args...> as{args...}; format_arg_store<context, Args...> as{args...};
return vfprintf(f, to_string_view(format), basic_format_args<context>(as)); return vfprintf(f, to_string_view(format), basic_format_args<context>(as));
} }
template <typename S, typename Char = FMT_CHAR(S)> template <typename S, typename Char = char_t<S>>
inline int vprintf( inline int vprintf(
const S& format, const S& format,
basic_format_args< basic_format_args<
@ -692,13 +689,13 @@ template <typename S, typename... Args,
FMT_ENABLE_IF(internal::is_string<S>::value)> FMT_ENABLE_IF(internal::is_string<S>::value)>
inline int printf(const S& format_str, const Args&... args) { inline int printf(const S& format_str, const Args&... args) {
internal::check_format_string<Args...>(format_str); internal::check_format_string<Args...>(format_str);
typedef internal::buffer<FMT_CHAR(S)> buffer; using buffer = internal::buffer<char_t<S>>;
typedef typename basic_printf_context_t<buffer>::type context; using context = typename basic_printf_context_t<buffer>::type;
format_arg_store<context, Args...> as{args...}; format_arg_store<context, Args...> as{args...};
return vprintf(to_string_view(format_str), basic_format_args<context>(as)); return vprintf(to_string_view(format_str), basic_format_args<context>(as));
} }
template <typename S, typename Char = FMT_CHAR(S)> template <typename S, typename Char = char_t<S>>
inline int vfprintf( inline int vfprintf(
std::basic_ostream<Char>& os, const S& format, std::basic_ostream<Char>& os, const S& format,
basic_format_args< basic_format_args<
@ -731,13 +728,11 @@ typename ArgFormatter::iterator vprintf(internal::buffer<Char>& out,
fmt::fprintf(cerr, "Don't %s!", "panic"); fmt::fprintf(cerr, "Don't %s!", "panic");
\endrst \endrst
*/ */
template <typename S, typename... Args, template <typename S, typename... Args, typename Char = char_t<S>>
FMT_ENABLE_IF(internal::is_string<S>::value)> inline int fprintf(std::basic_ostream<Char>& os, const S& format_str,
inline int fprintf(std::basic_ostream<FMT_CHAR(S)>& os, const S& format_str,
const Args&... args) { const Args&... args) {
internal::check_format_string<Args...>(format_str); internal::check_format_string<Args...>(format_str);
typedef internal::buffer<FMT_CHAR(S)> buffer; using context = typename basic_printf_context_t<internal::buffer<Char>>::type;
typedef typename basic_printf_context_t<buffer>::type context;
format_arg_store<context, Args...> as{args...}; format_arg_store<context, Args...> as{args...};
return vfprintf(os, to_string_view(format_str), return vfprintf(os, to_string_view(format_str),
basic_format_args<context>(as)); basic_format_args<context>(as));