From 106dc8fd642148828d63c69e9b534ccafd80f8d4 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 4 Sep 2024 16:23:51 -0700 Subject: [PATCH] Reduce usage of type_identity --- include/fmt/base.h | 18 ++++++------------ include/fmt/format.h | 5 +++++ include/fmt/ostream.h | 4 ++-- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/include/fmt/base.h b/include/fmt/base.h index a9a3a96b..9d8c54a9 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -334,10 +334,6 @@ template using remove_const_t = typename std::remove_const::type; template using remove_cvref_t = typename std::remove_cv>::type; -template struct type_identity { - using type = T; -}; -template using type_identity_t = typename type_identity::type; template using make_unsigned_t = typename std::make_unsigned::type; template @@ -449,9 +445,7 @@ FMT_CONSTEXPR auto to_unsigned(Int value) -> make_unsigned_t { } template -using unsigned_char = typename conditional_t::value, - std::make_unsigned, - type_identity>::type; +using unsigned_char = conditional_t; // A heuristic to detect std::string and std::[experimental::]string_view. // It is mainly used to avoid dependency on <[experimental/]string_view>. @@ -2176,6 +2170,11 @@ auto get_iterator(buffer&, OutputIt out) -> OutputIt { return out; } +// This type is intentionally undefined, only used for errors. +template struct type_is_unformattable_for; + +struct custom_tag {}; + template struct string_value { const Char* data; size_t size; @@ -2192,11 +2191,6 @@ template struct custom_value { void (*format)(void* arg, parse_context& parse_ctx, Context& ctx); }; -// This type is intentionally undefined, only used for errors. -template struct type_is_unformattable_for; - -struct custom_tag {}; - // A formatting argument value. template class value { public: diff --git a/include/fmt/format.h b/include/fmt/format.h index 6117ef45..061cb129 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -275,6 +275,11 @@ template struct is_contiguous> : std::true_type {}; +template struct type_identity { + using type = T; +}; +template using type_identity_t = typename type_identity::type; + namespace detail { FMT_CONSTEXPR inline void abort_fuzzing_if(bool condition) { diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index 2102f910..b215af28 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -161,10 +161,10 @@ inline void vprint_directly(std::ostream& os, string_view format_str, FMT_EXPORT template void vprint(std::basic_ostream& os, - basic_string_view> format_str, + basic_string_view> fmt, typename detail::vformat_args::type args) { auto buffer = basic_memory_buffer(); - detail::vformat_to(buffer, format_str, args); + detail::vformat_to(buffer, fmt, args); if (detail::write_ostream_unicode(os, {buffer.data(), buffer.size()})) return; detail::write_buffer(os, buffer); }