Is an is_functor C++ trait class possible?
问题 How can I deduce statically if an argument is a C++ function object (functor)? template <typename F> void test(F f) {} I tried is_function<F>::value , but this doesn't work. It also seems there is no is_functor trait, so perhaps it's not possible. I appear to be only looking for a specific member function, in this case the function call operator: F::operator() . 回答1: It is possible to create such a trait, with two restrictions: For the compiler, a free function is something fundamentally