In C++, why does <cctype> define both std::isspace and ::isspace?

Viewed 631

And why are most C++ compilers able to deduce the type of ::isspace and implicitly convert it to std::function, but they are not able to do so for std::isspace?

Please see the following which does not compile:

#include <cctype>
#include <functional>

template <typename Functish>
bool bar1(Functish f) { return f('a'); }

inline bool bar2(std::function<bool(char)> f) { return f('a'); }

#if 1
#define ff &std::isspace
#else
#define ff &::isspace
#endif

#if 0
bool foo()
{
    return bar1(ff);
}
#else
bool foo()
{
    return bar2(ff);
}
#endif

Of the compilers supported by Compiler Explorer, ELLCC seems to be the only one where std::isspace has the deducibility/convertibility that I would expect.

1 Answers
Related