Re:The C++14 Standard: What You Need to Know
by seren on Wednesday September 17, 2014 @10:05AM
(#8329980)
Now, for the fun part, imagine you have to integrate a third-party cpp library, with an API like "auto fooBar()".
[ Parent
| on HN ]
Re:The C++14 Standard: What You Need to Know
by Someone on Wednesday September 17, 2014 @01:41PM
(#8331255)
A 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/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-retur...: Of course, this requires the function body to be visible.
Re:The C++14 Standard: What You Need to Know
by dragonwriter on Wednesday September 17, 2014 @10:32AM
(#8330143)
Sure, 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++.