fork(2) download
  1. struct smth1
  2. {
  3. void f() {}
  4. } a1;
  5.  
  6. struct smth2
  7. {
  8. int f() { return 88; }
  9. } a2;
  10.  
  11. template <typename T> auto call(T *t)
  12. {
  13. return t ? t->f() : decltype (t->f()) {};
  14. }
  15.  
  16. int main()
  17. {
  18. call(&a1);
  19. call(&a2);
  20.  
  21. return 0;
  22. }
Compilation error #stdin compilation error #stdout 0s 4292KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘auto call(T*) [with T = smth1]’:
prog.cpp:18:11:   required from here
prog.cpp:13:12: error: compound literal of non-object type ‘void’
   return t ? t->f() : decltype (t->f()) {};
          ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stdout
Standard output is empty