I want to define a function of auto return type in such a way, that I can call it from multiple .cpp files if I include the header. I have 4 files
head.hpp
- where the function is
#ifndef HEAD_HPP#define HEAD_HPP auto f();#endif
head.cpp
- where the function is declared
#include "head.hpp"auto f(){ return [](){ return 10; };}
test1.cpp
- where it is used
#include "head.hpp"int foo(){ auto func = f(); return f();}
main.cpp
- where it is used as well
#include "head.hpp"int foo();int main(){ auto fu = f(); return fu() + 5 + foo();}
All files are compiled togetherI still get the error:
error: use of ‘auto f()’ before deduction of ‘auto’
auto fu = f();