[Development] RFC: more liberal 'auto' rules?

Matthew Woehlke mwoehlke.floss at gmail.com
Wed Dec 9 16:02:58 CET 2015

On 2015-12-09 08:15, Bubke Marco wrote:
> Should we recommend forward(universal) references in for loops (which are "const &value" for "const values"):
> for (auto &&value : values)

Someone remind me; what's the benefit of this vs. 'auto const&'
(assuming that I won't be modifying 'value')?

> or
> for (const auto &value : values)
> to show the difference to
> for (auto &value : values)

I personally prefer making everything I can 'const'. That means 'const&'
returns from functions ("forces" a copy elision), 'const' local
variables, etc.. In the case of loops like the above, if I'm not going
to modify the value, I prefer to say so. If I *am* going to modify it, I
prefer 'auto&' to a) also say so, and b) statically ensure that I *can*.

That's just my 2ยข however; I'd be interested in hearing arguments for


More information about the Development mailing list