--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
I would suggest one bit of rule relaxing vs google3, related to using "auto" with trailing function return types, when using in template context.I personally wouldn't care for (if not be outright against) using trailing return type syntax with regular functions like:int foo(); // goodauto foo() -> int; // why would you do this?But when working with templates, sometimes you can't do anything without this being allowed:template<typename U, typename V>auto multiply(U u, V v) -> decltype(u*v);Sure, this example relies on another feature, decltype in this case, but this is not strictly required.
I think that's a reasonable argument but should be discussed under a proposal about how to handle trailing return types instead of here. (I don't see trailing return types on the list of TBD features, it probably should be.)
--
The reason why I brought up trailing return type syntax because the subject of this thread is "auto". And not "auto for type inference".
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
What: Allow limited use of "auto" in place of an explicit typeWhy: Can improve readability in cases of local variables with long, boilerplate typenames, especially common when using STL containers or loop iteratorsWhy not: Egregious use of "auto" can harm readability
PK
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
-- BR Maciej Pawlowski Opera Desktop Wroclaw
W dniu 2014-09-25 01:14, 'Peter Kasting' via Chromium-dev pisze:
What: Allow limited use of "auto" in place of an explicit typeWhy: Can improve readability in cases of local variables with long, boilerplate typenames, especially common when using STL containers or loop iteratorsWhy not: Egregious use of "auto" can harm readability
+1
There are more reasons to use "auto" than just convenience. Herb Sutter had a nice talk on this during Cppcon 2014, the other arguments were:
- Guarantees no implicit conversion and narrowing.
- Potentialy less maintenance, ex. if you change a container type, you don't have rippling changes for all X::iterator declarations in code, "auto i = container.begin();" still works. When you change a container argument to const, you don't have to change X::iterator to X::const_iterator etc.
- Makes you focus on programming against interface rather than implementation, so more generic (in principle).
It's not a strongly typed interface, it's a duck-typed one. At scale it causes the same maintainability problems as weakly typed languages, and we don't have tools to debug type inference.
--
PK