Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2001-09-23 11:58:21


On Sunday, September 23, 2001, at 12:01 PM, Darin Adler wrote:

>> Are you completely sure that there are no real declarations?
>
> Yes, I'm sure. I've run into this problem before. There are many Unix
> systems that have these non-compliant <ctype.h> files that lack the
> functions.

Here's a technique that I've been looking at off and on for prototype
detection at compile time. I haven't worked a lot with it yet so it
still has some warts. But here it is if anyone wants to perhaps develop
and apply it to this situation. It is essentially a variation on the
is_convertable template. It is not completely portable, but I've no
doubt that the boost membership could improve upon the idea:

#include <cctype>

#undef isspace

namespace signatures
{
        char isspace(...);
}

namespace exists
{
        using namespace signatures;
        using namespace std;
        static bool const func_isspace = sizeof(isspace(0)) == sizeof(int);
}

#include <iostream>

int main()
{
        std::cout << exists::func_isspace << '\n';
}

-Howard


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk