Re:The C++14 Standard: What You Need to Know
by jibsen on Wednesday September 17, 2014 @10:39AM
(#8330193)
What happens if a header file declares a function to return auto, does the compiler have to wait until link time to find out what the type is?
[ Parent
| on HN ]
Re:The C++14 Standard: What You Need to Know
by missblit on Wednesday September 17, 2014 @11:04AM
(#8330329)
No, types are completely determined before link time.
An auto return type means the type is inferred from the type of the expression that the function returns, so it's known from that.
Re:The C++14 Standard: What You Need to Know
by seccess on Wednesday September 17, 2014 @12:56PM
(#8330978)
Interesting, could you elaborate on this a bit more?
Say I have a header file "foo.h" with an "auto foo();" declaration. Another file (eg, "bar.h") imports foo.h. How can the compiler do type checking when compiling bar.cc without also parsing foo.cc to determine the return type of foo()?
Re:The C++14 Standard: What You Need to Know
by nanofortnight on Wednesday September 17, 2014 @04:03PM
(#8332081)
Inferrence isn't magic and has sensible limits.
To quote:
> Of course, this requires the function body to be visible.
https://isocpp.org/wiki/faq/cpp14-language#generalized-retur...