Simplify the core API

This commit is contained in:
Victor Zverovich 2021-09-03 16:43:58 -07:00
parent fc0884037e
commit bf20d19901

View File

@ -2446,7 +2446,7 @@ FMT_CONSTEXPR auto parse_replacement_field(const Char* begin, const Char* end,
template <bool IS_CONSTEXPR, typename Char, typename Handler> template <bool IS_CONSTEXPR, typename Char, typename Handler>
FMT_CONSTEXPR FMT_INLINE void parse_format_string( FMT_CONSTEXPR FMT_INLINE void parse_format_string(
basic_string_view<Char> format_str, Handler&& handler) { basic_string_view<Char> 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; using detail::find;
auto begin = format_str.data(); auto begin = format_str.data();
@ -2722,16 +2722,11 @@ constexpr auto get_arg_index_by_name(basic_string_view<Char> name) -> int {
template <typename... Args, typename Char> template <typename... Args, typename Char>
FMT_CONSTEXPR auto get_arg_index_by_name(basic_string_view<Char> name) -> int { FMT_CONSTEXPR auto get_arg_index_by_name(basic_string_view<Char> name) -> int {
#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS #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); return get_arg_index_by_name<0, Args...>(name);
} else { #endif
(void)name;
return invalid_arg_index;
}
#else
(void)name; (void)name;
return invalid_arg_index; return invalid_arg_index;
#endif
} }
template <typename Char, typename ErrorHandler, typename... Args> template <typename Char, typename ErrorHandler, typename... Args>
@ -2967,7 +2962,7 @@ template <typename OutputIt,
auto vformat_to(OutputIt out, string_view fmt, format_args args) -> OutputIt { auto vformat_to(OutputIt out, string_view fmt, format_args args) -> OutputIt {
using detail::get_buffer; using detail::get_buffer;
auto&& buf = get_buffer<char>(out); auto&& buf = get_buffer<char>(out);
detail::vformat_to(buf, string_view(fmt), args, {}); detail::vformat_to(buf, fmt, args, {});
return detail::get_iterator(buf); return detail::get_iterator(buf);
} }
@ -3001,9 +2996,8 @@ template <typename OutputIt, typename... T,
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value)> FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value)>
auto vformat_to_n(OutputIt out, size_t n, string_view fmt, format_args args) auto vformat_to_n(OutputIt out, size_t n, string_view fmt, format_args args)
-> format_to_n_result<OutputIt> { -> format_to_n_result<OutputIt> {
using buffer = using traits = detail::fixed_buffer_traits;
detail::iterator_buffer<OutputIt, char, detail::fixed_buffer_traits>; auto buf = detail::iterator_buffer<OutputIt, char, traits>(out, n);
auto buf = buffer(out, n);
detail::vformat_to(buf, fmt, args, {}); detail::vformat_to(buf, fmt, args, {});
return {buf.out(), buf.count()}; return {buf.out(), buf.count()};
} }