mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-29 13:21:05 +00:00
Move more wchar overloads to wchar.h
This commit is contained in:
parent
0dd91e20d5
commit
9a92eb4158
@ -2718,10 +2718,6 @@ void vformat_to(
|
||||
basic_format_args<FMT_BUFFER_CONTEXT(type_identity_t<Char>)> args,
|
||||
detail::locale_ref loc = {});
|
||||
|
||||
template <typename Char, typename Args,
|
||||
FMT_ENABLE_IF(!std::is_same<Char, char>::value)>
|
||||
inline void vprint_mojibake(std::FILE*, basic_string_view<Char>, const Args&) {}
|
||||
|
||||
FMT_API void vprint_mojibake(std::FILE*, string_view, format_args);
|
||||
#ifndef _WIN32
|
||||
inline void vprint_mojibake(std::FILE*, string_view, format_args) {}
|
||||
@ -2949,8 +2945,8 @@ FMT_INLINE auto format(format_string<T...> str, T&&... args) -> std::string {
|
||||
return detail::vformat(str, make_format_args(args...));
|
||||
}
|
||||
|
||||
FMT_API void vprint(string_view, format_args);
|
||||
FMT_API void vprint(std::FILE*, string_view, format_args);
|
||||
FMT_API void vprint(string_view, format_args);
|
||||
|
||||
/**
|
||||
\rst
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include <cerrno> // errno
|
||||
#include <cmath> // std::signbit
|
||||
#include <cstdint>
|
||||
#include <cwchar>
|
||||
#include <limits> // std::numeric_limits
|
||||
#include <memory> // std::uninitialized_copy
|
||||
#include <stdexcept> // std::runtime_error
|
||||
@ -2667,22 +2666,6 @@ FMT_INLINE auto format(const S& format_str, Args&&... args)
|
||||
const auto& vargs = fmt::make_args_checked<Args...>(format_str, args...);
|
||||
return detail::vformat(to_string_view(format_str), vargs);
|
||||
}
|
||||
|
||||
template <typename Char, FMT_ENABLE_IF(std::is_same<Char, wchar_t>::value)>
|
||||
void vprint(std::FILE* f, basic_string_view<Char> format_str,
|
||||
wformat_args args) {
|
||||
wmemory_buffer buffer;
|
||||
detail::vformat_to(buffer, format_str, args);
|
||||
buffer.push_back(L'\0');
|
||||
if (std::fputws(buffer.data(), f) == -1)
|
||||
FMT_THROW(system_error(errno, "cannot write to file"));
|
||||
}
|
||||
|
||||
template <typename Char, FMT_ENABLE_IF(std::is_same<Char, wchar_t>::value)>
|
||||
void vprint(basic_string_view<Char> format_str, wformat_args args) {
|
||||
vprint(stdout, format_str, args);
|
||||
}
|
||||
|
||||
FMT_MODULE_EXPORT_END
|
||||
|
||||
#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS
|
||||
|
@ -8,6 +8,8 @@
|
||||
#ifndef FMT_WCHAR_H_
|
||||
#define FMT_WCHAR_H_
|
||||
|
||||
#include <cwchar>
|
||||
|
||||
#include "format.h"
|
||||
|
||||
namespace fmt {
|
||||
@ -26,13 +28,25 @@ constexpr format_arg_store<wformat_context, Args...> make_wformat_args(
|
||||
return {args...};
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void print(std::FILE* f, wformat_string<T...> str, T&&... args) {
|
||||
return vprint(f, wstring_view(str), make_wformat_args(args...));
|
||||
inline void vprint(std::FILE* f, wstring_view fmt, wformat_args args) {
|
||||
wmemory_buffer buffer;
|
||||
detail::vformat_to(buffer, fmt, args);
|
||||
buffer.push_back(L'\0');
|
||||
if (std::fputws(buffer.data(), f) == -1)
|
||||
FMT_THROW(system_error(errno, "cannot write to file"));
|
||||
}
|
||||
|
||||
template <typename... T> void print(wformat_string<T...> str, T&&... args) {
|
||||
return vprint(wstring_view(str), make_wformat_args(args...));
|
||||
inline void vprint(wstring_view fmt, wformat_args args) {
|
||||
vprint(stdout, fmt, args);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void print(std::FILE* f, wformat_string<T...> fmt, T&&... args) {
|
||||
return vprint(f, wstring_view(fmt), make_wformat_args(args...));
|
||||
}
|
||||
|
||||
template <typename... T> void print(wformat_string<T...> fmt, T&&... args) {
|
||||
return vprint(wstring_view(fmt), make_wformat_args(args...));
|
||||
}
|
||||
} // namespace fmt
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user