Add FMT_ENABLE_IF_T

for definitions of functions which declared using FMT_ENABLE_IF
This commit is contained in:
mocabe 2019-05-09 01:38:21 +09:00 committed by Victor Zverovich
parent 3fd134be03
commit 6828d549e8
4 changed files with 8 additions and 12 deletions

View File

@ -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);
}
@ -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);
}

View File

@ -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 {

View File

@ -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");

View File

@ -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 =