Subject: Re: A draft paper to fix the range-based for loop to make it teachable
From: Nicolai Josuttis (nico_at_[hidden])
Date: 2020-11-10 09:53:14
Am 10.11.2020 um 15:53 schrieb Yehezkel Bernat:
> On Tue, Nov 10, 2020 at 4:38 PM Amir Kirsh via SG20
> <sg20_at_[hidden] <mailto: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
> I don't think the standard library agrees. E.g.
> 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!
It should be not argument anymore.
I.E we definitely should NOT teach it with pseudo code but with a black
box like a function call.
Then we don't have to explain this anymore.
The problem right now is that we HAVE to show and explain the pseudo
code because to explain the problem.
-- Nicolai M. Josuttis www.josuttis.de +49 (0)531 / 129 88 86 +49 (0)700 / JOSUTTIS Books: C++: http://cppstdlib.com, http://cppstd17.com, http://tmplbook.com, http://cppmove.com SOA: http://soa-in-practice.com
SG20 list run by email@example.com
Older Archives on Google Groups