| ||||
| Comment on Reader Q&A: "Will C++ remain indispensable…?" by Matt Spatola
@Dain, I think the problem with this is that the problem with auto as a parameter like that is that C++ still only allows a single parameter type for a method. If you used auto to support more than one type, then you would be generating multiple methods, which is a bit surprising since it’s not a templated method. The alternative is for the auto to try to find a type that is implicitly convertible to from the types of all parameters that it is called with, also a bit surprising. Maybe I’m just missing something obvious, but with auto return type, you can easily deduce return type from what is being returned, and it will always be the same. If you want auto to work the same as a templated parameter type, I don’t see how to always generate a single method, and it seems odd for it to generate multiple methods. Read More »Comment on Reader Q&A: "Will C++ remain indispensable…?" by Herb Sutter
@Matt: Actually Bjarne’s auto/decltype proposal included auto parameters for implicit templates. That’s likely to still come back in the future. However, C++14 does already allow auto for parameters in lambda functions, so this is legal C++14 and actually often better than a hardcoded type: [](auto& coll, auto val){ coll.push_back(val); } Read More » | ||||
| | ||||
| ||||
Saturday, September 14, 2013
FeedaMail: Comments for Sutterâs Mill
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment