+1 to growing the list of use cases for 'auto' organically. I agree with Cody that using 'auto' for return type deduction should also be included, especially since we're already using it in libprocess.
On Mon, Sep 22, 2014 at 10:50 AM, Cody Maloney <[email protected]> wrote: > There are some cases where using auto for function return type deduction is > necessary to be able to state what you want generically in templates, and I > think we should allow that use case. I can ping some friends for good > examples if people would like. Definitely general use of return type > deduction shouldn't happen, but inside templates a lot of the time the code > is a lot simpler, more readable, and easier to maintain when using auto > (Esp. c++14 return type deduction auto), than if a type has to be > hand-deduced. > > Also note at times we just can't say what the type is, because it varies in > the template instantiation. See my use in > https://reviews.apache.org/r/25525/diff/, slaveinfo_utils.cpp where > writing explicit types for memberFunc is really hard if not impossible. > > On Mon, Sep 22, 2014 at 9:57 AM, Dominic Hamon <[email protected]> > wrote: > > > For reference: > > http://google-styleguide.googlecode.com/svn/trunk/cppguide.html#auto > > > > We should be able to adopt that wholesale but please document anywhere > you > > think we would diverge from those examples. > > > > On Mon, Sep 22, 2014 at 7:28 AM, Alex Rukletsov <[email protected]> > > wrote: > > > > > We now start using auto in the code (among several other C++11 > features). > > > However we don't want to hamper reasoning about types. I would suggest > we > > > select several use cases where we all agree using auto is welcomed and > > > several counterexamples. After the short conversation with BenH, we > > agreed > > > that iterators on one side and Try<>, Option<> on the other side are > > first > > > candidates for such list. I put the examples here > > > <https://reviews.apache.org/r/25622/>. > > > > > > Any thoughts and ideas? > > > > > > > > > > > -- > > Dominic Hamon | @mrdo | Twitter > > *There are no bad ideas; only good ideas that go horribly wrong.* > > >
