Provide typedefs for std::wstring and std::wostream

This is for systems with no libc support for wide character strings
(specifically djgpp).  libstdc++ then doesn't define these aliases,
but the primary templates are still available.
This commit is contained in:
J.W. Jagersma 2022-03-20 19:19:33 +01:00
parent 2d86bc4a79
commit 52c62ca386
No known key found for this signature in database
GPG Key ID: 438BF81BA7510C54
4 changed files with 10 additions and 3 deletions

View File

@ -300,6 +300,9 @@ FMT_GCC_PRAGMA("GCC optimize(\"Og\")")
FMT_BEGIN_NAMESPACE
FMT_MODULE_EXPORT_BEGIN
// Alias for older systems where std::wstring isn't defined.
using wstring = std::basic_string<wchar_t>;
// Implementations of enable_if_t and other metafunctions for older systems.
template <bool B, typename T = void>
using enable_if_t = typename std::enable_if<B, T>::type;

View File

@ -1232,7 +1232,7 @@ class utf8_to_utf16 {
operator basic_string_view<wchar_t>() const { return {&buffer_[0], size()}; }
auto size() const -> size_t { return buffer_.size() - 1; }
auto c_str() const -> const wchar_t* { return &buffer_[0]; }
auto str() const -> std::wstring { return {&buffer_[0], size()}; }
auto str() const -> wstring { return {&buffer_[0], size()}; }
};
namespace dragonbox {

View File

@ -138,9 +138,13 @@ void print(std::ostream& os, format_string<Args...> fmt, Args&&... args) {
vprint(os, fmt, fmt::make_format_args(args...));
}
// Alias for older systems where std::wostream isn't defined.
FMT_MODULE_EXPORT
using wostream = std::basic_ostream<wchar_t>;
FMT_MODULE_EXPORT
template <typename... Args>
void print(std::wostream& os,
void print(wostream& os,
basic_format_string<wchar_t, type_identity_t<Args>...> fmt,
Args&&... args) {
vprint(os, fmt, fmt::make_format_args<buffer_context<wchar_t>>(args...));

View File

@ -227,7 +227,7 @@ template <typename... T> void print(wformat_string<T...> fmt, T&&... args) {
/**
Converts *value* to ``std::wstring`` using the default format for type *T*.
*/
template <typename T> inline auto to_wstring(const T& value) -> std::wstring {
template <typename T> inline auto to_wstring(const T& value) -> wstring {
return format(FMT_STRING(L"{}"), value);
}
FMT_MODULE_EXPORT_END