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;
}