Skip to content

Commit 9db5e4d

Browse files
committed
Don't specialize std::is_floating_point
1 parent 906eaf2 commit 9db5e4d

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

include/fmt/format.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -721,11 +721,10 @@ struct float128 {};
721721

722722
template <typename T> using is_float128 = std::is_same<T, float128>;
723723

724-
template <typename T>
725-
using is_floating_point =
726-
bool_constant<std::is_floating_point<T>::value || is_float128<T>::value>;
724+
template <typename T> struct is_floating_point : std::is_floating_point<T> {};
725+
template <> struct is_floating_point<float128> : std::true_type {};
727726

728-
template <typename T, bool = std::is_floating_point<T>::value>
727+
template <typename T, bool = is_floating_point<T>::value>
729728
struct is_fast_float : bool_constant<std::numeric_limits<T>::is_iec559 &&
730729
sizeof(T) <= sizeof(double)> {};
731730
template <typename T> struct is_fast_float<T, false> : std::false_type {};
@@ -2472,8 +2471,8 @@ template <typename T>
24722471
struct has_isfinite<T, enable_if_t<sizeof(std::isfinite(T())) != 0>>
24732472
: std::true_type {};
24742473

2475-
template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value&&
2476-
has_isfinite<T>::value)>
2474+
template <typename T,
2475+
FMT_ENABLE_IF(is_floating_point<T>::value&& has_isfinite<T>::value)>
24772476
FMT_CONSTEXPR20 auto isfinite(T value) -> bool {
24782477
constexpr T inf = T(std::numeric_limits<double>::infinity());
24792478
if (is_constant_evaluated())

test/format-impl-test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,20 +307,20 @@ struct slow_float {
307307
auto format_as(slow_float f) -> float { return f; }
308308

309309
namespace std {
310-
template <> struct is_floating_point<double_double> : std::true_type {};
311310
template <> struct numeric_limits<double_double> {
312311
// is_iec559 is true for double-double in libstdc++.
313312
static constexpr bool is_iec559 = true;
314313
static constexpr int digits = 106;
315314
static constexpr int digits10 = 33;
316315
};
317316

318-
template <> struct is_floating_point<slow_float> : std::true_type {};
319317
template <> struct numeric_limits<slow_float> : numeric_limits<float> {};
320318
} // namespace std
321319

322320
FMT_BEGIN_NAMESPACE
323321
namespace detail {
322+
template <> struct is_floating_point<double_double> : std::true_type {};
323+
template <> struct is_floating_point<slow_float> : std::true_type {};
324324
template <> struct is_fast_float<slow_float> : std::false_type {};
325325
namespace dragonbox {
326326
template <> struct float_info<slow_float> {

0 commit comments

Comments
 (0)