fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<typename T>
  5. auto _test_hello_world_exists(T &f, int) -> decltype(f.helloworld()) {
  6. cout << "Has Helloworld" << endl;
  7. }
  8.  
  9. template<typename T>
  10. void _test_hello_world_exists(T &f, long) {
  11. cout << "hasen't helloworld" << endl;
  12. }
  13.  
  14. template<typename T>
  15. void test_hello_world_exists(T &f) {
  16. _test_hello_world_exists(f, 0);
  17. }
  18.  
  19. class has_helloworld_class {
  20. public:
  21. void helloworld() {};
  22. };
  23.  
  24. class no_helloworld_class {
  25. };
  26.  
  27. int main() {
  28. // your code goes here
  29. has_helloworld_class a;
  30. no_helloworld_class b;
  31. test_hello_world_exists(a);
  32. test_hello_world_exists(b);
  33. return 0;
  34. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
Has Helloworld
hasen't helloworld