mirror of
https://github.com/fmtlib/fmt.git
synced 2025-03-16 01:21:23 +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>
|
template <typename... T>
|
||||||
void print(FILE* f, const text_style& ts, format_string<T...> fmt,
|
void print(FILE* f, const text_style& ts, format_string<T...> fmt,
|
||||||
T&&... args) {
|
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>
|
template <typename... T>
|
||||||
inline auto format(const text_style& ts, format_string<T...> fmt, T&&... args)
|
inline auto format(const text_style& ts, format_string<T...> fmt, T&&... args)
|
||||||
-> std::string {
|
-> 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`.
|
/// 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)>
|
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value)>
|
||||||
inline auto format_to(OutputIt out, const text_style& ts,
|
inline auto format_to(OutputIt out, const text_style& ts,
|
||||||
format_string<T...> fmt, T&&... args) -> OutputIt {
|
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>
|
template <typename T, typename Char>
|
||||||
|
@ -3923,7 +3923,7 @@ FMT_API auto vsystem_error(int error_code, string_view format_str,
|
|||||||
template <typename... T>
|
template <typename... T>
|
||||||
auto system_error(int error_code, format_string<T...> fmt, T&&... args)
|
auto system_error(int error_code, format_string<T...> fmt, T&&... args)
|
||||||
-> std::system_error {
|
-> 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>
|
template <typename... T>
|
||||||
FMT_NODISCARD FMT_INLINE auto format(format_string<T...> fmt, T&&... args)
|
FMT_NODISCARD FMT_INLINE auto format(format_string<T...> fmt, T&&... args)
|
||||||
-> std::string {
|
-> 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)>
|
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)>
|
FMT_ENABLE_IF(detail::is_locale<Locale>::value)>
|
||||||
inline auto format(const Locale& loc, format_string<T...> fmt, T&&... args)
|
inline auto format(const Locale& loc, format_string<T...> fmt, T&&... args)
|
||||||
-> std::string {
|
-> 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,
|
template <typename OutputIt, typename Locale,
|
||||||
@ -4363,7 +4363,7 @@ template <typename OutputIt, typename Locale, typename... T,
|
|||||||
detail::is_locale<Locale>::value)>
|
detail::is_locale<Locale>::value)>
|
||||||
FMT_INLINE auto format_to(OutputIt out, const Locale& loc,
|
FMT_INLINE auto format_to(OutputIt out, const Locale& loc,
|
||||||
format_string<T...> fmt, T&&... args) -> OutputIt {
|
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,
|
template <typename Locale, typename... T,
|
||||||
@ -4372,8 +4372,7 @@ FMT_NODISCARD FMT_INLINE auto formatted_size(const Locale& loc,
|
|||||||
format_string<T...> fmt,
|
format_string<T...> fmt,
|
||||||
T&&... args) -> size_t {
|
T&&... args) -> size_t {
|
||||||
auto buf = detail::counting_buffer<>();
|
auto buf = detail::counting_buffer<>();
|
||||||
detail::vformat_to(buf, fmt, fmt::make_format_args(args...),
|
detail::vformat_to(buf, fmt, vargs<T...>{{args...}}, detail::locale_ref(loc));
|
||||||
detail::locale_ref(loc));
|
|
||||||
return buf.count();
|
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);
|
* "cannot open file '{}'", filename);
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
template <typename... Args>
|
template <typename... T>
|
||||||
std::system_error windows_error(int error_code, string_view message,
|
std::system_error windows_error(int error_code, string_view message,
|
||||||
const Args&... args) {
|
const T&... args) {
|
||||||
return vwindows_error(error_code, message, fmt::make_format_args(args...));
|
return vwindows_error(error_code, message, vargs<T...>{{args...}});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reports a Windows error without throwing an exception.
|
// Reports a Windows error without throwing an exception.
|
||||||
@ -213,7 +213,7 @@ class buffered_file {
|
|||||||
|
|
||||||
template <typename... T>
|
template <typename... T>
|
||||||
inline void print(string_view fmt, const T&... args) {
|
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)
|
detail::is_locking<T...>() ? fmt::vprint_buffered(file_, fmt, vargs)
|
||||||
: fmt::vprint(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
|
/// Formats `args` according to specifications in `fmt` and writes the
|
||||||
/// output to the file.
|
/// output to the file.
|
||||||
template <typename... T> void print(format_string<T...> fmt, T&&... args) {
|
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,11 +178,9 @@ void vprint(std::basic_ostream<Char>& os,
|
|||||||
*/
|
*/
|
||||||
FMT_EXPORT template <typename... T>
|
FMT_EXPORT template <typename... T>
|
||||||
void print(std::ostream& os, format_string<T...> fmt, T&&... args) {
|
void print(std::ostream& os, format_string<T...> fmt, T&&... args) {
|
||||||
const auto& vargs = fmt::make_format_args(args...);
|
fmt::vargs<T...> vargs = {{args...}};
|
||||||
if (FMT_USE_UTF8)
|
if (FMT_USE_UTF8) return vprint(os, fmt, vargs);
|
||||||
vprint(os, fmt, vargs);
|
detail::vprint_directly(os, fmt, vargs);
|
||||||
else
|
|
||||||
detail::vprint_directly(os, fmt, vargs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_EXPORT
|
FMT_EXPORT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user