Possible Duplicate:
Is it possible to write a C++ template to check for a function's existence?
This is very similar to my earlier question. I want to check whether a template argument contains a member function or not.
I tried this code similar to that in the accepted answer in my previous question.
struct A
{
int member_func();
};
struct B
{
};
template<typename T>
struct has_member_func
{
template<typename C> static char func(???); //what should I put in place of '???'
template<typename C> static int func(...);
enum{val = sizeof(func<T>(0)) == 1};
};
int main()
{
std::cout<< has_member_func<B>::val; //should output 0
std::cout<< has_member_func<A>::val; //should output 1
}
But I have no idea what should I put in place of ???
to make it work.
I am new to SFINAE concept.