Subject: Re: [boost] usage of auto in tutorials
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2019-03-19 20:52:11
wt., 19 mar 2019 o 19:07 Paul A. Bristow via Boost <boost_at_[hidden]>
> > -----Original Message-----
> > From: Boost [mailto:boost-bounces_at_[hidden]] On Behalf Of Andrzej
> Krzemienski via Boost
> > Sent: 19 March 2019 15:49
> > To: boost_at_[hidden]
> > Cc: Andrzej Krzemienski
> > Subject: Re: [boost] usage of auto in tutorials
> > wt., 19 mar 2019 o 16:37 mike via Boost <boost_at_[hidden]>
> > > > -----Original Message-----
> > > > From: Boost <boost-bounces_at_[hidden]> On Behalf Of Stephan
> > > via Boost
> > >
> > > My personal rule of thumb for tutorial and demos is similar to how
> > > you handle abbreviations in written text:
> > >
> > > First time you e.g. use a function, you explicitly show what the
> > > function returns. Afterwards I use auto where it makes sense
> > > (And yes, I know there are conflicting opinions about
> > > "where it makes sense").
> > >
> > > With respect to the specific examples:
> > > - Trailing return types in function declarations:
> > > If the style guide doesn't say something different, I only use
> > > them for very long type names and when they are needed.
> > > None of this applies here, so I don't see the benefit,
> > > but also not any harm. I'd say it is personal/project preference.
> > > - The auto inside the if:
> > > The return type of the function is shown just two lines above.
> > > Again, personal opinion, but I'd claim it even increases
> > > readability, because it is less visual noise.
> > I wonder what others in this group think? Maybe we could come up with
> > guidelines for documentation writers.
> I think that auto should be used sparingly in examples whose purpose is
An auxiliary question: does your guideline apply to `auto` used for type
inference, or does it also apply to `auto` for trailing return type (where
no deduction takes place).
> Examples of where one *must use auto* are the exception rather than the
> rule, and usually worthy of special note.
> The main benefit of auto is 'syntactic sugar' for the writer, not the
> Spelling out the type is usually an important part of illustrating the
> My 2p FWIW.
> Paul A. Bristow
> Prizet Farmhouse
> Kendal UK LA8 8AB
> +44 (0) 1539 561830
> Unsubscribe & other changes:
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk