fork download
  1. #include <iostream>
  2.  
  3. struct S{bool operator()(){return true;}};
  4.  
  5. template <class TFunctor>
  6. class TIsCallable
  7. {
  8. typedef char TTwoChars[2];
  9. template <class T>
  10. static char Test(int[sizeof((*((T*)0))()) ? 1 : -1] = 0);
  11.  
  12. template <class>
  13. static TTwoChars& Test(...);
  14. public:
  15. static const bool Value_ = sizeof(Test<TFunctor>(0)) == 1;
  16. };
  17.  
  18. int main()
  19. {
  20. std::cout << TIsCallable<int>::Value_ << TIsCallable<int (*)()>::Value_
  21. << TIsCallable<S>::Value_ << std::endl;
  22. }
  23.  
Success #stdin #stdout 0.02s 2724KB
stdin
Standard input is empty
stdout
111