I have is_callable trait defined like this:
#ifndef IS_CALLABLE_HPP
#define IS_CALLABLE_HPP
#include
namespace is_callable_detail
{
If you know in advance operator()
is not going to be overloaded, you can try to take its address. If operator()
is possibly overloaded, then a positive result would mean that there is an operator()
present but a negative result would mean that either no operator()
is present, or at least two overloads are.
Notice that a template will (as expected) bring several overloads of operator()
. However, if you do know the number of template parameters that are not defaulted you can try taking the address of operator()
(for some type T
that hopefully won't trigger SFINAE).
As a final note, I'd suggest not trying to spend too much time trying to inspect functors (or member functions, for the same reasons) without knowing what arguments to pass, just like what you already have. C++11 makes it very easy to write and use generic code that functions at the expression level.