Consider the following:
struct A {
typedef int foo;
};
struct B {};
template
struct C {};
I wa
Another (C++03) approach:
template
struct has_foo
{
private:
typedef char no;
struct yes { no m[2]; };
static T* make();
template
static yes check(U*, typename U::foo* = 0);
static no check(...);
public:
static bool const value = sizeof(check(make())) == sizeof(yes);
};
struct A
{
typedef int foo;
};
struct B { };
template::value>
struct C
{
// T has foo
};
template
struct C
{
// T has no foo
};