diff --git a/include/fmt/format.h b/include/fmt/format.h index ede3f7ac479ab..295d935dbfac0 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3569,19 +3569,31 @@ inline format_to_n_result vformat_to_n( end of the output range. \endrst */ -template -inline format_to_n_result format_to_n( - OutputIt out, std::size_t n, string_view format_str, const Args &... args) { - return vformat_to_n( - out, n, format_str, make_format_to_n_args(args...)); +template +inline typename std::enable_if< + internal::is_format_string::value && + std::is_same::value, + format_to_n_result>::type format_to_n( + OutputIt out, std::size_t n, const String &format_str, const Args &... args) { + internal::check_format_string(format_str); + typedef FMT_CHAR(String) char_t; + typedef format_to_n_context context_t; + format_arg_store as{ args... }; + return vformat_to_n(out, n, basic_string_view(format_str), as); } -template -inline format_to_n_result format_to_n( - OutputIt out, std::size_t n, wstring_view format_str, - const Args &... args) { + +template +inline typename std::enable_if< + internal::is_format_string::value && + !std::is_same::value, + format_to_n_result>::type format_to_n( + OutputIt out, std::size_t n, const String &format_str, const Args &... args) { + internal::check_format_string(format_str); + typedef FMT_CHAR(String) char_t; typedef internal::truncating_iterator It; - auto it = vformat_to(It(out, n), format_str, - make_format_args::type>(args...)); + typedef typename format_context_t::type context_t; + format_arg_store as{ args... }; + auto it = vformat_to(It(out, n), basic_string_view(format_str), as); return {it.base(), it.count()}; }