From 971f7ae7689f418bcd32e8bab95dda4db6442e61 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 10 Jan 2024 16:43:00 -0800 Subject: [PATCH] Minor cleanup --- include/fmt/base.h | 7 ------- include/fmt/printf.h | 19 ++++++------------- include/fmt/xchar.h | 7 ++++--- test/printf-test.cc | 5 +++-- test/ranges-test.cc | 4 ++-- 5 files changed, 15 insertions(+), 27 deletions(-) diff --git a/include/fmt/base.h b/include/fmt/base.h index e1226670..b9df9cdc 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -1490,10 +1490,8 @@ constexpr unsigned long long make_descriptor() { : is_unpacked_bit | NUM_ARGS; } -#if defined(__cpp_if_constexpr) // This type is intentionally undefined, only used for errors template struct type_is_unformattable_for; -#endif template FMT_CONSTEXPR auto make_arg(T& val) -> value { @@ -1918,11 +1916,6 @@ constexpr auto make_format_args(T&... args) return {args...}; } -// DEPRECATED! -template -using format_arg_store = - decltype(make_format_args(std::declval()...)); - /** \rst Returns a named argument to be used in a formatting function. diff --git a/include/fmt/printf.h b/include/fmt/printf.h index 8cb7f01f..b7b31cb8 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -573,17 +573,10 @@ using wprintf_args = basic_format_args; arguments and can be implicitly converted to `~fmt::printf_args`. \endrst */ -template -inline auto make_printf_args(const T&... args) - -> format_arg_store { - return {args...}; -} - -// DEPRECATED! -template -inline auto make_wprintf_args(const T&... args) - -> format_arg_store { - return {args...}; +template +inline auto make_printf_args(T&... args) + -> decltype(make_format_args>(args...)) { + return make_format_args>(args...); } template struct vprintf_args { @@ -637,7 +630,7 @@ inline auto vfprintf(std::FILE* f, basic_string_view fmt, template > inline auto fprintf(std::FILE* f, const S& fmt, const T&... args) -> int { return vfprintf(f, detail::to_string_view(fmt), - fmt::make_format_args>(args...)); + make_printf_args(args...)); } template @@ -663,7 +656,7 @@ inline auto printf(string_view fmt, const T&... args) -> int { template FMT_DEPRECATED inline auto printf(basic_string_view fmt, const T&... args) -> int { - return vfprintf(stdout, fmt, make_wprintf_args(args...)); + return vfprintf(stdout, fmt, make_printf_args(args...)); } FMT_END_EXPORT diff --git a/include/fmt/xchar.h b/include/fmt/xchar.h index 4a048fbd..57eab890 100644 --- a/include/fmt/xchar.h +++ b/include/fmt/xchar.h @@ -88,7 +88,7 @@ template <> struct is_char : std::true_type {}; template constexpr auto make_wformat_args(T&... args) - -> format_arg_store { + -> decltype(make_format_args(args...)) { return make_format_args(args...); } @@ -167,8 +167,9 @@ template ::value)> inline auto format(const Locale& loc, const S& format_str, T&&... args) -> std::basic_string { - return detail::vformat(loc, detail::to_string_view(format_str), - fmt::make_format_args>(args...)); + return detail::vformat( + loc, detail::to_string_view(format_str), + fmt::make_format_args>(args...)); } template (L"[%d] %s happened"), - {fmt::make_wprintf_args(42, L"something")})); + {fmt::make_printf_args(n, L"something")})); } diff --git a/test/ranges-test.cc b/test/ranges-test.cc index 4eafcbe1..fd569c67 100644 --- a/test/ranges-test.cc +++ b/test/ranges-test.cc @@ -596,8 +596,8 @@ TEST(ranges_test, format_as_tie) { struct lvalue_qualified_begin_end { int arr[5] = {1, 2, 3, 4, 5}; - int const* begin() & { return arr; } - int const* end() & { return arr + 5; } + auto begin() & -> const int* { return arr; } + auto end() & -> const int* { return arr + 5; } }; TEST(ranges_test, lvalue_qualified_begin_end) {