// Formatting library for C++ - optional wchar_t support // // Copyright (c) 2012 - present, Victor Zverovich // All rights reserved. // // For the license information refer to format.h. #ifndef FMT_WCHAR_H_ #define FMT_WCHAR_H_ #include #include "format.h" FMT_BEGIN_NAMESPACE FMT_MODULE_EXPORT_BEGIN using wformat_parse_context = basic_format_parse_context; using wformat_context = buffer_context; using wformat_args = basic_format_args; #if FMT_GCC_VERSION && FMT_GCC_VERSION < 409 // Workaround broken conversion on older gcc. template using wformat_string = wstring_view; #else template using wformat_string = basic_format_string...>; #endif template constexpr format_arg_store make_wformat_args( const Args&... args) { return {args...}; } inline namespace literals { constexpr auto operator"" _format(const wchar_t* s, size_t n) -> detail::udl_formatter { return {{s, n}}; } } // namespace literals 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")); } inline void vprint(wstring_view fmt, wformat_args args) { vprint(stdout, fmt, args); } template void print(std::FILE* f, wformat_string fmt, T&&... args) { return vprint(f, wstring_view(fmt), make_wformat_args(args...)); } template void print(wformat_string fmt, T&&... args) { return vprint(wstring_view(fmt), make_wformat_args(args...)); } FMT_MODULE_EXPORT_END FMT_END_NAMESPACE #endif // FMT_WCHAR_H_