Skip to content

std::isfinite() does not accept convertible-to-double #23081

@eugenis

Description

@eugenis
Bugzilla Link 22707
Resolution DUPLICATE
Resolved on Feb 26, 2015 08:02
Version unspecified
OS Linux
CC @mclow

Extended Description

#include

struct A {
A(double x) : x(x) {}
operator double() const { return x; }

double x;
};

A a(1.0);
bool z = std::isfinite(a);

error: no matching function for call to 'isfinite'
bool z = std::isfinite(a);
^~~~~~~~~~~~~
/code/llvm/build/bin/../include/c++/v1/cmath:376:25: note: candidate template ignored: disabled by 'enable_if' [with _A1 = A]
typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type

The Standard requires an overload of
bool isfinite(double x);

Instead, libc++ provides a template implementation with a SFINAE checking for an arithmetic type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzilladuplicateResolved as duplicatelibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions