mirror of
https://github.com/fmtlib/fmt.git
synced 2025-08-02 12:14:43 +02:00
Minor cleanup
This commit is contained in:
@@ -1490,10 +1490,8 @@ constexpr unsigned long long make_descriptor() {
|
|||||||
: is_unpacked_bit | NUM_ARGS;
|
: is_unpacked_bit | NUM_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__cpp_if_constexpr)
|
|
||||||
// This type is intentionally undefined, only used for errors
|
// This type is intentionally undefined, only used for errors
|
||||||
template <typename T, typename Char> struct type_is_unformattable_for;
|
template <typename T, typename Char> struct type_is_unformattable_for;
|
||||||
#endif
|
|
||||||
|
|
||||||
template <bool PACKED, typename Context, typename T, FMT_ENABLE_IF(PACKED)>
|
template <bool PACKED, typename Context, typename T, FMT_ENABLE_IF(PACKED)>
|
||||||
FMT_CONSTEXPR auto make_arg(T& val) -> value<Context> {
|
FMT_CONSTEXPR auto make_arg(T& val) -> value<Context> {
|
||||||
@@ -1918,11 +1916,6 @@ constexpr auto make_format_args(T&... args)
|
|||||||
return {args...};
|
return {args...};
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEPRECATED!
|
|
||||||
template <typename Context, typename... T>
|
|
||||||
using format_arg_store =
|
|
||||||
decltype(make_format_args<Context>(std::declval<T&>()...));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\rst
|
\rst
|
||||||
Returns a named argument to be used in a formatting function.
|
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`.
|
arguments and can be implicitly converted to `~fmt::printf_args`.
|
||||||
\endrst
|
\endrst
|
||||||
*/
|
*/
|
||||||
template <typename... T>
|
template <typename Char = char, typename... T>
|
||||||
inline auto make_printf_args(const T&... args)
|
inline auto make_printf_args(T&... args)
|
||||||
-> format_arg_store<printf_context, T...> {
|
-> decltype(make_format_args<basic_printf_context<Char>>(args...)) {
|
||||||
return {args...};
|
return make_format_args<basic_printf_context<Char>>(args...);
|
||||||
}
|
|
||||||
|
|
||||||
// DEPRECATED!
|
|
||||||
template <typename... T>
|
|
||||||
inline auto make_wprintf_args(const T&... args)
|
|
||||||
-> format_arg_store<wprintf_context, T...> {
|
|
||||||
return {args...};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char> struct vprintf_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>>
|
template <typename S, typename... T, typename Char = char_t<S>>
|
||||||
inline auto fprintf(std::FILE* f, const S& fmt, const T&... args) -> int {
|
inline auto fprintf(std::FILE* f, const S& fmt, const T&... args) -> int {
|
||||||
return vfprintf(f, detail::to_string_view(fmt),
|
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>
|
template <typename Char>
|
||||||
@@ -663,7 +656,7 @@ inline auto printf(string_view fmt, const T&... args) -> int {
|
|||||||
template <typename... T>
|
template <typename... T>
|
||||||
FMT_DEPRECATED inline auto printf(basic_string_view<wchar_t> fmt,
|
FMT_DEPRECATED inline auto printf(basic_string_view<wchar_t> fmt,
|
||||||
const T&... args) -> int {
|
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
|
FMT_END_EXPORT
|
||||||
|
@@ -88,7 +88,7 @@ template <> struct is_char<char32_t> : std::true_type {};
|
|||||||
|
|
||||||
template <typename... T>
|
template <typename... T>
|
||||||
constexpr auto make_wformat_args(T&... args)
|
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...);
|
return make_format_args<wformat_context>(args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +167,8 @@ template <typename Locale, typename S, typename... T,
|
|||||||
detail::is_exotic_char<Char>::value)>
|
detail::is_exotic_char<Char>::value)>
|
||||||
inline auto format(const Locale& loc, const S& format_str, T&&... args)
|
inline auto format(const Locale& loc, const S& format_str, T&&... args)
|
||||||
-> std::basic_string<Char> {
|
-> std::basic_string<Char> {
|
||||||
return detail::vformat(loc, detail::to_string_view(format_str),
|
return detail::vformat(
|
||||||
|
loc, detail::to_string_view(format_str),
|
||||||
fmt::make_format_args<buffered_context<Char>>(args...));
|
fmt::make_format_args<buffered_context<Char>>(args...));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -550,10 +550,11 @@ TEST(printf_test, fixed_large_exponent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(printf_test, make_printf_args) {
|
TEST(printf_test, make_printf_args) {
|
||||||
|
int n = 42;
|
||||||
EXPECT_EQ("[42] something happened",
|
EXPECT_EQ("[42] something happened",
|
||||||
fmt::vsprintf(fmt::string_view("[%d] %s 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",
|
EXPECT_EQ(L"[42] something happened",
|
||||||
fmt::vsprintf(fmt::basic_string_view<wchar_t>(L"[%d] %s 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 {
|
struct lvalue_qualified_begin_end {
|
||||||
int arr[5] = {1, 2, 3, 4, 5};
|
int arr[5] = {1, 2, 3, 4, 5};
|
||||||
|
|
||||||
int const* begin() & { return arr; }
|
auto begin() & -> const int* { return arr; }
|
||||||
int const* end() & { return arr + 5; }
|
auto end() & -> const int* { return arr + 5; }
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST(ranges_test, lvalue_qualified_begin_end) {
|
TEST(ranges_test, lvalue_qualified_begin_end) {
|
||||||
|
Reference in New Issue
Block a user