File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,18 @@ _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfin
5555 return true ;
5656}
5757
58+ _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite (float __x) _NOEXCEPT {
59+ return __builtin_isfinite (__x);
60+ }
61+
62+ _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite (double __x) _NOEXCEPT {
63+ return __builtin_isfinite (__x);
64+ }
65+
66+ _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite (long double __x) _NOEXCEPT {
67+ return __builtin_isfinite (__x);
68+ }
69+
5870// isinf
5971
6072template <class _A1 , __enable_if_t <is_arithmetic<_A1>::value && numeric_limits<_A1>::has_infinity, int > = 0 >
Original file line number Diff line number Diff line change @@ -62,9 +62,21 @@ struct TestInt {
6262 }
6363};
6464
65+ template <typename T>
66+ struct ConvertibleTo {
67+ operator T () const { return T (); }
68+ };
69+
6570int main (int , char **) {
6671 types::for_each (types::floating_point_types (), TestFloat ());
6772 types::for_each (types::integral_types (), TestInt ());
6873
74+ // Make sure we can call `std::isfinite` with convertible types
75+ {
76+ assert (std::isfinite (ConvertibleTo<float >()));
77+ assert (std::isfinite (ConvertibleTo<double >()));
78+ assert (std::isfinite (ConvertibleTo<long double >()));
79+ }
80+
6981 return 0 ;
7082}
You can’t perform that action at this time.
0 commit comments