[libcxx-commits] [libcxx] [libc++] Fix acceptance of convertible-to-{float, double, long double} in std::isfinite() (PR #98841)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jul 16 07:20:40 PDT 2024
================
@@ -62,9 +62,30 @@ struct TestInt {
}
};
+struct ConvertibleFloat {
+ int value;
+ ConvertibleFloat(int v) : value(v) {}
+ operator float() const { return static_cast<float>(value); }
+};
+
+struct ConvertibleDouble {
+ int value;
+ ConvertibleDouble(int v) : value(v) {}
+ operator double() const { return static_cast<double>(value); }
+};
+
+struct ConvertibleLongDouble {
+ int value;
+ ConvertibleLongDouble(int v) : value(v) {}
+ operator long double() const { return static_cast<long double>(value); }
+};
+
----------------
philnik777 wrote:
```suggestion
template <class T>
struct ConvertibleTo {
operator T() const { return {}; }
};
```
And then use `ConvertibleTo<float>` below.
https://github.com/llvm/llvm-project/pull/98841
More information about the libcxx-commits
mailing list