fork(3) download
  1. #include <iostream>
  2.  
  3. template<typename T>
  4. class test
  5. {
  6. template <void*>
  7. struct Nothing
  8. {
  9. typedef char type;
  10. };
  11.  
  12. template <typename U>
  13. static typename Nothing<&U::operator()>::type check(int);
  14.  
  15. template <typename>
  16. static int check(char);
  17.  
  18. public:
  19.  
  20. static const bool is_functor = sizeof(check<T>(0)) == 1;
  21. };
  22.  
  23. struct a{};
  24. struct b
  25. {
  26. void operator() (){}
  27. };
  28.  
  29. int main()
  30. {
  31. std::cout << test<a>::is_functor << '\n';
  32. std::cout << test<b>::is_functor << '\n';
  33. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
0
0