Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c++
Subject: Re: thread about the pros and cons of lambdas, but more about cons
Date: Thu, 26 Sep 2024 10:01:11 -0700
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <8634lm73jc.fsf@linuxsc.com>
References: <20240925195423.00007ecc@yahoo.com> <871q17idqr.fsf@bsb.me.uk> <87v7yjgyfq.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Thu, 26 Sep 2024 19:01:12 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="fcae6191366e67ac7893d7838d1abab6"; logging-data="284655"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/5DE/uleXevRK/j2BFaWuY8l5Jn3EB/gg="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:Tz9aG/wo9GmIfXIvXht7sWNLugY= sha1:w7jIcRDIUqyVU+d/8dbYZnKVzXY=
Xref: csiph.com comp.lang.c++:120383
Ben Bacarisse writes:
> Ben Bacarisse writes:
>
>> ... You can,
>> instead, do this (untested):
>
> I should have tested! Of course you have to change the capture (at
> least for core) from '=' to '&':
>
>> #include
>>
>> int floodfill4(
>> unsigned char *grey,
>> int width, int height,
>> int x, int y,
>> unsigned char target, unsigned char dest)
>> {
>> if (width < 1 || height < 1)
>> return 0;
>> if (x < 0 || x >= width || y < 0 || y >= height)
>> return 0;
>>
>> size_t w = width, h = height;
>> if (grey[y*w+x] != target)
>> return 0;
>>
>> std::function core;
>> core = [&] (size_t x, size_t y) {
>
> Corrected-----^
Why do you think [&] should be used instead of [=]?