#include <iostream>

template <bool, typename=void> struct enable_if {};
template <typename T> struct enable_if<true, T> { typedef T type; };

template <typename T> T declval();

template<typename T>
class test
{
	typedef char yes[1];
    typedef char no[2];
    
	template <typename U>
    static yes& check2(U T::*);
    
    template <typename U>
    static typename enable_if<sizeof(check2(&U::operator()))==sizeof(yes), yes>::type& check(U);
 
    static no& check(...);
 
public:
 
    static const bool is_functor = sizeof(check(declval<T>())) == 1;
};

struct a{};
struct b
{
	const volatile void operator() (a,a,a) const volatile {}
};

int main()
{
	std::cout << test<a>::is_functor << '\n';
	std::cout << test<b>::is_functor << '\n';
}