diff --git a/libcxx/test/std/numerics/c.math/isfinite.pass.cpp b/libcxx/test/std/numerics/c.math/isfinite.pass.cpp index 35a054c5bcd52c..3d5be616343343 100644 --- a/libcxx/test/std/numerics/c.math/isfinite.pass.cpp +++ b/libcxx/test/std/numerics/c.math/isfinite.pass.cpp @@ -62,30 +62,21 @@ struct TestInt { } }; -struct ConvertibleFloat { - int value; - ConvertibleFloat(int v) : value(v) {} - operator float() const { return static_cast(value); } -}; - -struct ConvertibleDouble { - int value; - ConvertibleDouble(int v) : value(v) {} - operator double() const { return static_cast(value); } -}; - -struct ConvertibleLongDouble { - int value; - ConvertibleLongDouble(int v) : value(v) {} - operator long double() const { return static_cast(value); } +template +struct ConvertibleTo { + operator T() const { return T(); } }; int main(int, char**) { types::for_each(types::floating_point_types(), TestFloat()); types::for_each(types::integral_types(), TestInt()); - assert(std::isfinite(ConvertibleFloat(0))); - assert(std::isfinite(ConvertibleDouble(0))); - assert(std::isfinite(ConvertibleLongDouble(0))); + + // Make sure we can call `std::isfinite` with convertible types + { + assert(std::isfinite(ConvertibleTo())); + assert(std::isfinite(ConvertibleTo())); + assert(std::isfinite(ConvertibleTo())); + } return 0; }