// Example program
#include <iostream>
#include <string>

namespace mpl {

template<typename ...>
struct void_type
{
    using type = void;
};

template<typename ...T>
using void_t = typename void_type<T...>::type;

} // namespace mpl

#define CAN_CALL_METHOD(NAME) \
namespace internal { \
template<typename T, typename ...Args> \
using result_of_call_method_##NAME = decltype( \
    std::declval<T>().NAME(std::declval<Args>()...)); \
} \
template<typename T, typename Signature, typename = void> \
struct can_call_method_##NAME: std::false_type \
{}; \
template<typename T, typename ...Args> \
struct can_call_method_##NAME<T, void(Args...), \
    mpl::void_t<internal::result_of_call_method_##NAME<T, Args...>> \
    >: std::true_type \
{}; \
template<typename T, typename R, typename ...Args> \
struct can_call_method_##NAME<T, R(Args...), \
    typename std::enable_if<!std::is_void<R>::value && \
                             std::is_convertible<internal::result_of_call_method_##NAME<T, Args...>, R \
                                                >::value \
                           >::type \
    >: std::true_type \
{}; 

CAN_CALL_METHOD(hello);

struct Foo {
  template <typename T>
  void hello(T&) {}
};

struct Foo1 {
};

int main()
{
  std::cout << std::boolalpha;
  std::cout << can_call_method_hello<Foo, void(int&)>::value << std::endl;
  std::cout << can_call_method_hello<Foo1, void(int&)>::value << std::endl;
}
