C++ Logo


Advanced search

Subject: Re: Possible defect: unneeded const in lambda capture
From: Ville Voutilainen (ville.voutilainen_at_[hidden])
Date: 2019-08-29 13:40:20

On Thu, 29 Aug 2019 at 21:35, Roman Odaisky via Std-Discussion
<std-discussion_at_[hidden]> wrote:
> > Such plausible cases have been explained before when this matter has come
> > up. Transformation from a loop to an algorithm that uses a lambda was the
> > original motivation.
> Certainly the user would use a [&] lambda for that? And if the nature of the
> algorithm is such that the lambda is stored somewhere and can outlive its
> calling scope, necessitating storage of captured values, that's precisely the
> use case I started with, which takes advantage of non-const members because
> they can be moved.

Would they? If the algorithm runs in multiple threads, they might want
a copy and don't
really care whether the lambda can or can't be moved from, because
it's copied into multiple

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups