mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-08 12:20:06 +00:00
Switch to vargs
This commit is contained in:
parent
debf6f8285
commit
cad876be4c
@ -485,7 +485,7 @@ inline void vprint(FILE* f, const text_style& ts, string_view fmt,
|
||||
template <typename... T>
|
||||
void print(FILE* f, const text_style& ts, format_string<T...> fmt,
|
||||
T&&... args) {
|
||||
vprint(f, ts, fmt, fmt::make_format_args(args...));
|
||||
vprint(f, ts, fmt, vargs<T...>{{args...}});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -524,7 +524,7 @@ inline auto vformat(const text_style& ts, string_view fmt, format_args args)
|
||||
template <typename... T>
|
||||
inline auto format(const text_style& ts, format_string<T...> fmt, T&&... args)
|
||||
-> std::string {
|
||||
return fmt::vformat(ts, fmt, fmt::make_format_args(args...));
|
||||
return fmt::vformat(ts, fmt, vargs<T...>{{args...}});
|
||||
}
|
||||
|
||||
/// Formats a string with the given text_style and writes the output to `out`.
|
||||
@ -551,7 +551,7 @@ template <typename OutputIt, typename... T,
|
||||
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value)>
|
||||
inline auto format_to(OutputIt out, const text_style& ts,
|
||||
format_string<T...> fmt, T&&... args) -> OutputIt {
|
||||
return vformat_to(out, ts, fmt, fmt::make_format_args(args...));
|
||||
return vformat_to(out, ts, fmt, vargs<T...>{{args...}});
|
||||
}
|
||||
|
||||
template <typename T, typename Char>
|
||||
|
@ -3923,7 +3923,7 @@ FMT_API auto vsystem_error(int error_code, string_view format_str,
|
||||
template <typename... T>
|
||||
auto system_error(int error_code, format_string<T...> fmt, T&&... args)
|
||||
-> std::system_error {
|
||||
return vsystem_error(error_code, fmt, fmt::make_format_args(args...));
|
||||
return vsystem_error(error_code, fmt, vargs<T...>{{args...}});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4331,7 +4331,7 @@ FMT_API auto vformat(string_view fmt, format_args args) -> std::string;
|
||||
template <typename... T>
|
||||
FMT_NODISCARD FMT_INLINE auto format(format_string<T...> fmt, T&&... args)
|
||||
-> std::string {
|
||||
return vformat(fmt, fmt::make_format_args(args...));
|
||||
return vformat(fmt, vargs<T...>{{args...}});
|
||||
}
|
||||
|
||||
template <typename Locale, FMT_ENABLE_IF(detail::is_locale<Locale>::value)>
|
||||
@ -4344,7 +4344,7 @@ template <typename Locale, typename... T,
|
||||
FMT_ENABLE_IF(detail::is_locale<Locale>::value)>
|
||||
inline auto format(const Locale& loc, format_string<T...> fmt, T&&... args)
|
||||
-> std::string {
|
||||
return fmt::vformat(loc, string_view(fmt), fmt::make_format_args(args...));
|
||||
return fmt::vformat(loc, string_view(fmt), vargs<T...>{{args...}});
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename Locale,
|
||||
@ -4363,7 +4363,7 @@ template <typename OutputIt, typename Locale, typename... T,
|
||||
detail::is_locale<Locale>::value)>
|
||||
FMT_INLINE auto format_to(OutputIt out, const Locale& loc,
|
||||
format_string<T...> fmt, T&&... args) -> OutputIt {
|
||||
return vformat_to(out, loc, fmt, fmt::make_format_args(args...));
|
||||
return vformat_to(out, loc, fmt, vargs<T...>{{args...}});
|
||||
}
|
||||
|
||||
template <typename Locale, typename... T,
|
||||
@ -4372,8 +4372,7 @@ FMT_NODISCARD FMT_INLINE auto formatted_size(const Locale& loc,
|
||||
format_string<T...> fmt,
|
||||
T&&... args) -> size_t {
|
||||
auto buf = detail::counting_buffer<>();
|
||||
detail::vformat_to(buf, fmt, fmt::make_format_args(args...),
|
||||
detail::locale_ref(loc));
|
||||
detail::vformat_to(buf, fmt, vargs<T...>{{args...}}, detail::locale_ref(loc));
|
||||
return buf.count();
|
||||
}
|
||||
|
||||
|
@ -146,10 +146,10 @@ FMT_API std::system_error vwindows_error(int error_code, string_view format_str,
|
||||
* "cannot open file '{}'", filename);
|
||||
* }
|
||||
*/
|
||||
template <typename... Args>
|
||||
template <typename... T>
|
||||
std::system_error windows_error(int error_code, string_view message,
|
||||
const Args&... args) {
|
||||
return vwindows_error(error_code, message, fmt::make_format_args(args...));
|
||||
const T&... args) {
|
||||
return vwindows_error(error_code, message, vargs<T...>{{args...}});
|
||||
}
|
||||
|
||||
// Reports a Windows error without throwing an exception.
|
||||
@ -213,7 +213,7 @@ class buffered_file {
|
||||
|
||||
template <typename... T>
|
||||
inline void print(string_view fmt, const T&... args) {
|
||||
const auto& vargs = fmt::make_format_args(args...);
|
||||
fmt::vargs<T...> vargs = {{args...}};
|
||||
detail::is_locking<T...>() ? fmt::vprint_buffered(file_, fmt, vargs)
|
||||
: fmt::vprint(file_, fmt, vargs);
|
||||
}
|
||||
@ -398,7 +398,7 @@ class FMT_API ostream : private detail::buffer<char> {
|
||||
/// Formats `args` according to specifications in `fmt` and writes the
|
||||
/// output to the file.
|
||||
template <typename... T> void print(format_string<T...> fmt, T&&... args) {
|
||||
vformat_to(appender(*this), fmt, fmt::make_format_args(args...));
|
||||
vformat_to(appender(*this), fmt, vargs<T...>{{args...}});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -178,10 +178,8 @@ void vprint(std::basic_ostream<Char>& os,
|
||||
*/
|
||||
FMT_EXPORT template <typename... T>
|
||||
void print(std::ostream& os, format_string<T...> fmt, T&&... args) {
|
||||
const auto& vargs = fmt::make_format_args(args...);
|
||||
if (FMT_USE_UTF8)
|
||||
vprint(os, fmt, vargs);
|
||||
else
|
||||
fmt::vargs<T...> vargs = {{args...}};
|
||||
if (FMT_USE_UTF8) return vprint(os, fmt, vargs);
|
||||
detail::vprint_directly(os, fmt, vargs);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user