[PATCH] D31561: cmath: Skip Libc for integral types in isinf, etc.

Hal Finkel via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 10 12:28:56 PDT 2017


hfinkel added inline comments.


================
Comment at: libcxx/include/math.h:354
 inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
+typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
 signbit(_A1 __lcpp_x) _NOEXCEPT
----------------
I think that it would be safer / easier to understand if we used !std::is_integral here. It is true for all standard types that std::is_arithmetic implies is_integral or is_floating_point, but it seems likely that some implementations have arithemtic types that are neither (e.g. fixed-point types), and user-defined types seem likely.


================
Comment at: libcxx/include/math.h:400
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_integral<_A1>::value, int>::type
+fpclassify(_A1 __lcpp_x) _NOEXCEPT
----------------
Maybe we should predicate this, and other infinity-related functions, on std::numeric_limits<_A1>::has_infinity. That seems more general, and safer for potential user-defined types.


https://reviews.llvm.org/D31561





More information about the cfe-commits mailing list