C++ Logo

SG20

Advanced search

Subject: Re: A draft paper to fix the range-based for loop to make it teachable
From: Yehezkel Bernat (yehezkelshb_at_[hidden])
Date: 2020-11-10 08:53:12


On Tue, Nov 10, 2020 at 4:38 PM Amir Kirsh via SG20 <sg20_at_[hidden]>
wrote:

> For example: don't return a const reference to a parameter that you got
> as const ref. It might be a temporary (great example I send my students to is
> here <http://www.youtube.com/watch?v=lkgszkPnV8g&t=13m0s>).
>
>
I don't think the standard library agrees. E.g.
https://en.cppreference.com/w/cpp/algorithm/min
This is probably the responsibility of the caller to not hold things as
references in such cases.

> But fixing just the range-based-for may lead to even more confusion.
>

I like this argument!

>



SG20 list run by sg20-owner@lists.isocpp.org

Older Archives on Google Groups