Workaround a bug in MSVC

This commit is contained in:
Victor Zverovich 2017-08-20 10:02:08 -07:00
parent 5e0562ab51
commit 70ef82a8e3
2 changed files with 8 additions and 4 deletions

View File

@ -3575,6 +3575,12 @@ const Char *do_format_arg(basic_buffer<Char> &buffer,
return pointer_from(it);
}
// Specifies whether to format T using the standard formatter.
// It is not possible to use gettype in formatter specialization directly
// because of a bug in MSVC.
template <typename T>
struct format_type : std::integral_constant<bool, gettype<T>() != CUSTOM> {};
// Specifies whether to format enums.
template <typename T, typename Enable = void>
struct format_enum : std::integral_constant<bool, std::is_enum<T>::value> {};
@ -3582,8 +3588,7 @@ struct format_enum : std::integral_constant<bool, std::is_enum<T>::value> {};
// Formatter of objects of type T.
template <typename T, typename Char>
struct formatter<T, Char,
typename std::enable_if<internal::gettype<T>() != internal::CUSTOM>::type> {
struct formatter<T, Char, typename std::enable_if<internal::format_type<T>::value>::type> {
// Parses format specifiers stopping either at the end of the range or at the
// terminating '}'.

View File

@ -87,8 +87,7 @@ struct format_enum<T,
// Formats an object of type T that has an overloaded ostream operator<<.
template <typename T, typename Char>
struct formatter<T, Char,
typename std::enable_if<
internal::gettype<T>() == internal::CUSTOM>::type>
typename std::enable_if<!internal::format_type<T>::value>::type>
: formatter<basic_string_view<Char>, Char> {
void format(basic_buffer<Char> &buf, const T &value,