From bf20d19901dd55a25186bfd1359ece99e123ed65 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 3 Sep 2021 16:43:58 -0700 Subject: [PATCH] Simplify the core API --- include/fmt/core.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index dd05f99f..0c8ddd18 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -2446,7 +2446,7 @@ FMT_CONSTEXPR auto parse_replacement_field(const Char* begin, const Char* end, template FMT_CONSTEXPR FMT_INLINE void parse_format_string( basic_string_view format_str, Handler&& handler) { - // this is most likely a name-lookup defect in msvc's modules implementation + // Workaround a name-lookup bug in MSVC's modules implementation. using detail::find; auto begin = format_str.data(); @@ -2722,16 +2722,11 @@ constexpr auto get_arg_index_by_name(basic_string_view name) -> int { template FMT_CONSTEXPR auto get_arg_index_by_name(basic_string_view name) -> int { #if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS - if constexpr (sizeof...(Args) > 0) { + if constexpr (sizeof...(Args) > 0) return get_arg_index_by_name<0, Args...>(name); - } else { - (void)name; - return invalid_arg_index; - } -#else +#endif (void)name; return invalid_arg_index; -#endif } template @@ -2967,7 +2962,7 @@ template OutputIt { using detail::get_buffer; auto&& buf = get_buffer(out); - detail::vformat_to(buf, string_view(fmt), args, {}); + detail::vformat_to(buf, fmt, args, {}); return detail::get_iterator(buf); } @@ -3001,9 +2996,8 @@ template ::value)> auto vformat_to_n(OutputIt out, size_t n, string_view fmt, format_args args) -> format_to_n_result { - using buffer = - detail::iterator_buffer; - auto buf = buffer(out, n); + using traits = detail::fixed_buffer_traits; + auto buf = detail::iterator_buffer(out, n); detail::vformat_to(buf, fmt, args, {}); return {buf.out(), buf.count()}; }