How do I deduce auto before a function is called?

Viewed 7078

while experimenting with function return type deduction

auto func();

int main() { func(); }

auto func() { return 0; }

error: use of ‘auto func()’ before deduction of ‘auto’

Is there a way to use this feature without needing to specify the definition before the call? With a large call tree, it becomes complicated to re-arrange functions so that their definition is seen before all of the places they are called. Surely an evaluation could be held off until a particular function definition was found and auto could then be deduced.

4 Answers
Related