mirror of
https://github.com/fmtlib/fmt.git
synced 2025-03-30 04:20:58 +00:00
Minor cleanup
This commit is contained in:
parent
6159e2b0ab
commit
971f7ae768
@ -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 <typename T, typename Char> struct type_is_unformattable_for;
|
||||
#endif
|
||||
|
||||
template <bool PACKED, typename Context, typename T, FMT_ENABLE_IF(PACKED)>
|
||||
FMT_CONSTEXPR auto make_arg(T& val) -> value<Context> {
|
||||
@ -1918,11 +1916,6 @@ constexpr auto make_format_args(T&... args)
|
||||
return {args...};
|
||||
}
|
||||
|
||||
// DEPRECATED!
|
||||
template <typename Context, typename... T>
|
||||
using format_arg_store =
|
||||
decltype(make_format_args<Context>(std::declval<T&>()...));
|
||||
|
||||
/**
|
||||
\rst
|
||||
Returns a named argument to be used in a formatting function.
|
||||
|
@ -573,17 +573,10 @@ using wprintf_args = basic_format_args<wprintf_context>;
|
||||
arguments and can be implicitly converted to `~fmt::printf_args`.
|
||||
\endrst
|
||||
*/
|
||||
template <typename... T>
|
||||
inline auto make_printf_args(const T&... args)
|
||||
-> format_arg_store<printf_context, T...> {
|
||||
return {args...};
|
||||
}
|
||||
|
||||
// DEPRECATED!
|
||||
template <typename... T>
|
||||
inline auto make_wprintf_args(const T&... args)
|
||||
-> format_arg_store<wprintf_context, T...> {
|
||||
return {args...};
|
||||
template <typename Char = char, typename... T>
|
||||
inline auto make_printf_args(T&... args)
|
||||
-> decltype(make_format_args<basic_printf_context<Char>>(args...)) {
|
||||
return make_format_args<basic_printf_context<Char>>(args...);
|
||||
}
|
||||
|
||||
template <typename Char> struct vprintf_args {
|
||||
@ -637,7 +630,7 @@ inline auto vfprintf(std::FILE* f, basic_string_view<Char> fmt,
|
||||
template <typename S, typename... T, typename Char = char_t<S>>
|
||||
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<basic_printf_context<Char>>(args...));
|
||||
make_printf_args<Char>(args...));
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
@ -663,7 +656,7 @@ inline auto printf(string_view fmt, const T&... args) -> int {
|
||||
template <typename... T>
|
||||
FMT_DEPRECATED inline auto printf(basic_string_view<wchar_t> fmt,
|
||||
const T&... args) -> int {
|
||||
return vfprintf(stdout, fmt, make_wprintf_args(args...));
|
||||
return vfprintf(stdout, fmt, make_printf_args<wchar_t>(args...));
|
||||
}
|
||||
|
||||
FMT_END_EXPORT
|
||||
|
@ -88,7 +88,7 @@ template <> struct is_char<char32_t> : std::true_type {};
|
||||
|
||||
template <typename... T>
|
||||
constexpr auto make_wformat_args(T&... args)
|
||||
-> format_arg_store<wformat_context, T...> {
|
||||
-> decltype(make_format_args<wformat_context>(args...)) {
|
||||
return make_format_args<wformat_context>(args...);
|
||||
}
|
||||
|
||||
@ -167,8 +167,9 @@ template <typename Locale, typename S, typename... T,
|
||||
detail::is_exotic_char<Char>::value)>
|
||||
inline auto format(const Locale& loc, const S& format_str, T&&... args)
|
||||
-> std::basic_string<Char> {
|
||||
return detail::vformat(loc, detail::to_string_view(format_str),
|
||||
fmt::make_format_args<buffered_context<Char>>(args...));
|
||||
return detail::vformat(
|
||||
loc, detail::to_string_view(format_str),
|
||||
fmt::make_format_args<buffered_context<Char>>(args...));
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename S,
|
||||
|
@ -550,10 +550,11 @@ TEST(printf_test, fixed_large_exponent) {
|
||||
}
|
||||
|
||||
TEST(printf_test, make_printf_args) {
|
||||
int n = 42;
|
||||
EXPECT_EQ("[42] something happened",
|
||||
fmt::vsprintf(fmt::string_view("[%d] %s happened"),
|
||||
{fmt::make_printf_args(42, "something")}));
|
||||
{fmt::make_printf_args(n, "something")}));
|
||||
EXPECT_EQ(L"[42] something happened",
|
||||
fmt::vsprintf(fmt::basic_string_view<wchar_t>(L"[%d] %s happened"),
|
||||
{fmt::make_wprintf_args(42, L"something")}));
|
||||
{fmt::make_printf_args<wchar_t>(n, L"something")}));
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user