Add is_exotic_char trait

This commit is contained in:
Victor Zverovich 2021-05-23 19:50:17 -07:00
parent bc13c6de39
commit 0c0926395d

View File

@ -13,6 +13,11 @@
#include "format.h" #include "format.h"
FMT_BEGIN_NAMESPACE FMT_BEGIN_NAMESPACE
namespace detail {
template <typename T>
using is_exotic_char = bool_constant<!std::is_same<T, char>::value>;
}
FMT_MODULE_EXPORT_BEGIN FMT_MODULE_EXPORT_BEGIN
using wstring_view = basic_string_view<wchar_t>; using wstring_view = basic_string_view<wchar_t>;
@ -65,8 +70,8 @@ arg_join<const T*, const T*, wchar_t> join(std::initializer_list<T> list,
} }
template <typename Locale, typename S, typename Char = char_t<S>, template <typename Locale, typename S, typename Char = char_t<S>,
FMT_ENABLE_IF(detail::is_locale<Locale>::value && FMT_ENABLE_IF(detail::is_locale<Locale>::value&&
!std::is_same<Char, char>::value)> detail::is_exotic_char<Char>::value)>
inline std::basic_string<Char> vformat( inline std::basic_string<Char> vformat(
const Locale& loc, const S& format_str, const Locale& loc, const S& format_str,
basic_format_args<buffer_context<type_identity_t<Char>>> args) { basic_format_args<buffer_context<type_identity_t<Char>>> args) {
@ -75,8 +80,8 @@ inline std::basic_string<Char> vformat(
template <typename Locale, typename S, typename... Args, template <typename Locale, typename S, typename... Args,
typename Char = char_t<S>, typename Char = char_t<S>,
FMT_ENABLE_IF(detail::is_locale<Locale>::value && FMT_ENABLE_IF(detail::is_locale<Locale>::value&&
!std::is_same<Char, char>::value)> detail::is_exotic_char<Char>::value)>
inline std::basic_string<Char> format(const Locale& loc, const S& format_str, inline std::basic_string<Char> format(const Locale& loc, const S& format_str,
Args&&... args) { Args&&... args) {
return detail::vformat(loc, to_string_view(format_str), return detail::vformat(loc, to_string_view(format_str),
@ -86,8 +91,8 @@ inline std::basic_string<Char> format(const Locale& loc, const S& format_str,
template <typename Locale, typename S, typename OutputIt, typename... Args, template <typename Locale, typename S, typename OutputIt, typename... Args,
typename Char = char_t<S>, typename Char = char_t<S>,
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value&& FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value&&
detail::is_locale<Locale>::value && detail::is_locale<Locale>::value&&
!std::is_same<Char, char>::value)> detail::is_exotic_char<Char>::value)>
inline OutputIt vformat_to( inline OutputIt vformat_to(
OutputIt out, const Locale& loc, const S& format_str, OutputIt out, const Locale& loc, const S& format_str,
basic_format_args<buffer_context<type_identity_t<Char>>> args) { basic_format_args<buffer_context<type_identity_t<Char>>> args) {
@ -96,11 +101,11 @@ inline OutputIt vformat_to(
return detail::get_iterator(buf); return detail::get_iterator(buf);
} }
template <typename OutputIt, typename Locale, typename S, typename... Args, template <
typename Char = char_t<S>, typename OutputIt, typename Locale, typename S, typename... Args,
bool enable = detail::is_output_iterator<OutputIt, Char>::value&& typename Char = char_t<S>,
detail::is_locale<Locale>::value && bool enable = detail::is_output_iterator<OutputIt, Char>::value&&
!std::is_same<Char, char>::value> detail::is_locale<Locale>::value&& detail::is_exotic_char<Char>::value>
inline auto format_to(OutputIt out, const Locale& loc, const S& format_str, inline auto format_to(OutputIt out, const Locale& loc, const S& format_str,
Args&&... args) -> Args&&... args) ->
typename std::enable_if<enable, OutputIt>::type { typename std::enable_if<enable, OutputIt>::type {