@benh: It doesn't look like we're not using auto for return type deduction
yet. (Perhaps you're thinking about: auto f(...) -> return_type { ... })

Return type deduction using auto is a C++14 feature. We explicitly don't
support gcc-4.7 due to its lack of C++11 features, so I'll start at gcc-4.8.

gcc-4.8 with -std=c++11 supports auto for return type deduction by default
with warnings, but gcc-4.9  requires -std=c++1y or -std=c++14 to be
specified.

clang-3.3 requires -std=c++1y as well. I don't actually have clang-3.4 at
the moment so I'm not sure, but clang-3.5 also requires -std=c++1y so I
imagine clang-3.4 does the same.

So in order to get auto for return type deduction I think we'd have to flip
it up to -std=c++1y or -std=c++14. Thoughts?

On 25 September 2014 05:36, Benjamin Hindman <b...@eecs.berkeley.edu> wrote:

> +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 <c...@mesosphere.io> 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 <dha...@twopensource.com>
> > 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 <a...@mesosphere.io>
> > > 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.*
> > >
> >
>

Reply via email to