Skip to content

Fix compilation error under MSVC 19.21 (#1140) #1150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions include/fmt/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,11 @@ struct chrono_format_checker {
FMT_NORETURN void on_tz_name() { report_no_date(); }
};

template <typename T,
typename std::enable_if<std::is_integral<T>::value, int>::type = 0>
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
inline bool isnan(T) {
return false;
}
template <typename T, typename std::enable_if<std::is_floating_point<T>::value,
int>::type = 0>
template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value)>
inline bool isnan(T value) {
return std::isnan(value);
}
Expand All @@ -394,13 +392,11 @@ template <typename T> inline int to_int(T value) {
return static_cast<int>(value);
}

template <typename T,
typename std::enable_if<std::is_integral<T>::value, int>::type = 0>
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
inline T mod(T x, int y) {
return x % y;
}
template <typename T, typename std::enable_if<std::is_floating_point<T>::value,
int>::type = 0>
template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value)>
inline T mod(T x, int y) {
return std::fmod(x, y);
}
Expand Down
3 changes: 2 additions & 1 deletion include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@

// An enable_if helper to be used in template parameters. enable_if in template
// parameters results in much shorter symbols: https://godbolt.org/z/sWw4vP.
#define FMT_ENABLE_IF(...) typename std::enable_if<__VA_ARGS__, int>::type = 0
#define FMT_ENABLE_IF_T(...) typename std::enable_if<(__VA_ARGS__), int>::type
#define FMT_ENABLE_IF(...) FMT_ENABLE_IF_T(__VA_ARGS__) = 0

FMT_BEGIN_NAMESPACE
namespace internal {
Expand Down
3 changes: 1 addition & 2 deletions include/fmt/format-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,7 @@ template <int GRISU_VERSION> struct grisu_shortest_handler {
}
};

template <typename Double, typename std::enable_if<
sizeof(Double) == sizeof(uint64_t), int>::type>
template <typename Double, FMT_ENABLE_IF_T(sizeof(Double) == sizeof(uint64_t))>
FMT_FUNC bool grisu_format(Double value, buffer<char>& buf, int precision,
unsigned options, int& exp) {
FMT_ASSERT(value >= 0, "value is negative");
Expand Down
2 changes: 1 addition & 1 deletion include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -2239,7 +2239,7 @@ FMT_CONSTEXPR bool do_check_format_string(basic_string_view<Char> s,
}

template <typename... Args, typename S,
typename std::enable_if<is_compile_string<S>::value, int>::type>
FMT_ENABLE_IF_T(is_compile_string<S>::value)>
void check_format_string(S format_str) {
typedef typename S::char_type char_t;
FMT_CONSTEXPR_DECL bool invalid_format =
Expand Down