5 ms·
Now, for the fun part, imagine you have to integrate a third-party cpp library, with an API like "auto fooBar()".
by seren 12y ago
Now, for the fun part, imagine you have to integrate a third-party cpp library, with an API like "auto fooBar()".
- dragonwriter 12y agoSure, auto probably shouldn't be used on a function that's part of the exposed API of a library, rather than something internal to the unit of code it is part of. Its kind of weird to see people complaining about a C++ feature because its not appropriate to use indiscriminately and requires some discipline -- that's historically been pretty much the whole of C/C++.
- seren 12y agoMy comment was mostly tongue-in-cheek, it will be misused in some time and place, but is not a serious issue.
- Someone 12y agoA third party can do that but if it doesn't also provide the source for fooBar, you won't be able to call it, making it fairly useless. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3638.html http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n363...: Of course, using such a function in an expression when only a forward declaration has been seen is ill-formed: auto f(); // return type is unknown int i = f(); // error, return type of f is unknown And https://isocpp.org/wiki/faq/cpp14-language#generalized-return https://isocpp.org/wiki/faq/cpp14-language#generalized-retur...: Of course, this requires the function body to be visible.