From 3a5e19fbf5070fb50936d86ececc79506748ae91 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 25 Dec 2022 08:28:40 -0800 Subject: [PATCH] Minor cleanup --- include/fmt/core.h | 22 ++++++++++------------ include/fmt/xchar.h | 4 +++- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 1f20044f..2f3cc61f 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -2942,8 +2942,7 @@ inline void vprint_mojibake(std::FILE*, string_view, format_args) {} #endif FMT_END_DETAIL_NAMESPACE -// A formatter specialization for the core types corresponding to detail::type -// constants. +// A formatter specialization for natively supported types. template struct formatter::value != @@ -2952,8 +2951,6 @@ struct formatter specs_; public: - // Parses format specifiers stopping either at the end of the range or at the - // terminating '}'. template FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { auto begin = ctx.begin(), end = ctx.end(); @@ -3019,10 +3016,9 @@ struct formatter::value, - enable_if_t<(U == detail::type::string_type || - U == detail::type::cstring_type || - U == detail::type::char_type), - int> = 0> + FMT_ENABLE_IF(U == detail::type::string_type || + U == detail::type::cstring_type || + U == detail::type::char_type)> FMT_CONSTEXPR void set_debug_format(bool set = true) { specs_.type = set ? presentation_type::debug : presentation_type::none; } @@ -3036,7 +3032,7 @@ struct formatter \ struct formatter : formatter { \ template \ - auto format(Type const& val, FormatContext& ctx) const \ + auto format(const Type& val, FormatContext& ctx) const \ -> decltype(ctx.out()) { \ return formatter::format(static_cast(val), ctx); \ } \ @@ -3053,7 +3049,9 @@ FMT_FORMAT_AS(std::basic_string, basic_string_view); FMT_FORMAT_AS(std::nullptr_t, const void*); FMT_FORMAT_AS(detail::std_string_view, basic_string_view); -template struct basic_runtime { basic_string_view str; }; +template struct runtime_format_string { + basic_string_view str; +}; /** A compile-time format string. */ template class basic_format_string { @@ -3081,7 +3079,7 @@ template class basic_format_string { detail::check_format_string(s); #endif } - basic_format_string(basic_runtime r) : str_(r.str) {} + basic_format_string(runtime_format_string fmt) : str_(fmt.str) {} FMT_INLINE operator basic_string_view() const { return str_; } FMT_INLINE basic_string_view get() const { return str_; } @@ -3104,7 +3102,7 @@ using format_string = basic_format_string...>; fmt::print(fmt::runtime("{:d}"), "I am not a number"); \endrst */ -inline auto runtime(string_view s) -> basic_runtime { return {{s}}; } +inline auto runtime(string_view s) -> runtime_format_string<> { return {{s}}; } #endif FMT_API auto vformat(string_view fmt, format_args args) -> std::string; diff --git a/include/fmt/xchar.h b/include/fmt/xchar.h index a48684e4..5b0cf4d4 100644 --- a/include/fmt/xchar.h +++ b/include/fmt/xchar.h @@ -52,7 +52,9 @@ inline auto runtime(wstring_view s) -> wstring_view { return s; } #else template using wformat_string = basic_format_string...>; -inline auto runtime(wstring_view s) -> basic_runtime { return {{s}}; } +inline auto runtime(wstring_view s) -> runtime_format_string { + return {{s}}; +} #endif template <> struct is_char : std::true_type {};