struct smth1 { void f() {} } a1; struct smth2 { int f() { return 88; } } a2; template <typename T> auto call(T *t) { return t ? t->f() : decltype (t->f()) {}; } int main() { call(&a1); call(&a2); return 0; }
Standard input is empty
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()) {}; ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Standard output is empty