Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #120413
| Path | csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Michael S <already5chosen@yahoo.com> |
| Newsgroups | comp.lang.c++ |
| Subject | Re: thread about the pros and cons of lambdas, but more about cons |
| Date | Fri, 27 Sep 2024 16:27:13 +0300 |
| Organization | A noiseless patient Spider |
| Lines | 56 |
| Message-ID | <20240927162713.000060ea@yahoo.com> (permalink) |
| References | <20240925195423.00007ecc@yahoo.com> <871q17idqr.fsf@bsb.me.uk> <87v7yjgyfq.fsf@bsb.me.uk> <8634lm73jc.fsf@linuxsc.com> <20240926202050.00002d46@yahoo.com> <86tte25n9h.fsf@linuxsc.com> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Fri, 27 Sep 2024 15:27:21 +0200 (CEST) |
| Injection-Info | dont-email.me; posting-host="1ce4012f9af3aefde3b6d3b61642343a"; logging-data="793974"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19IuUeqFvyMOfNhLaj8pw7o5cCBXsJrVoE=" |
| Cancel-Lock | sha1:HpSeUHl2ycS5HA5LI3MyIZrUpoo= |
| X-Newsreader | Claws Mail 4.1.1 (GTK 3.24.34; x86_64-w64-mingw32) |
| Xref | csiph.com comp.lang.c++:120413 |
Show key headers only | View raw
On Thu, 26 Sep 2024 10:38:02 -0700
Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
> Michael S <already5chosen@yahoo.com> writes:
>
> > On Thu, 26 Sep 2024 10:01:11 -0700
> > Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
> >
> >> Ben Bacarisse <ben@bsb.me.uk> writes:
> >>
> >>> Ben Bacarisse <ben@bsb.me.uk> 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 <functional>
> >>>>
> >>>> 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<void(size_t, size_t)> core;
> >>>> core = [&] (size_t x, size_t y) {
> >>>
> >>> Corrected-----^
> >>
> >> Why do you think [&] should be used instead of [=]?
> >
> > Compiler says that otherwise 'core' captures itself before it
> > properly initialize.
> > And indeed, it does not work (Segmentation fault).
>
> Ahh. A chicken and egg problem. I sidestepped that by initializing
> 'core' as part of its declaration (as my other response to Ben
> shows).
>
> No compiler warning, but I didn't try running it.
It does not make any difference. The same crash as before.
BTW, I am surprised that your compiler issues no warning.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar
thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-25 19:54 +0300
Re: thread about the pros and cons of lambdas, but more about cons Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-25 19:17 +0200
Re: thread about the pros and cons of lambdas, but more about cons Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-25 19:55 +0200
Re: thread about the pros and cons of lambdas, but more about cons Paavo Helde <eesnimi@osa.pri.ee> - 2024-09-25 22:53 +0300
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-25 23:30 +0300
Re: thread about the pros and cons of lambdas, but more about cons Paavo Helde <eesnimi@osa.pri.ee> - 2024-09-26 00:04 +0300
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-26 11:17 +0300
Re: thread about the pros and cons of lambdas, but more about cons Paavo Helde <eesnimi@osa.pri.ee> - 2024-09-26 11:25 +0300
Re: thread about the pros and cons of lambdas, but more about cons Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-26 10:28 +0200
Re: thread about the pros and cons of lambdas, but more about cons Paavo Helde <eesnimi@osa.pri.ee> - 2024-09-26 11:49 +0300
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-26 11:38 +0300
Re: thread about the pros and cons of lambdas, but more about cons Ben Bacarisse <ben@bsb.me.uk> - 2024-09-25 23:13 +0100
Re: thread about the pros and cons of lambdas, but more about cons Ben Bacarisse <ben@bsb.me.uk> - 2024-09-25 23:28 +0100
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-26 10:41 +0300
Re: thread about the pros and cons of lambdas, but more about cons David Brown <david.brown@hesbynett.no> - 2024-09-26 10:29 +0200
Re: thread about the pros and cons of lambdas, but more about cons Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-26 11:35 +0200
Re: thread about the pros and cons of lambdas, but more about cons David Brown <david.brown@hesbynett.no> - 2024-09-26 13:27 +0200
Re: thread about the pros and cons of lambdas, but more about cons Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-26 13:31 +0200
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-26 15:25 +0300
Re: thread about the pros and cons of lambdas, but more about cons Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-26 14:58 +0200
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-26 16:53 +0300
Re: thread about the pros and cons of lambdas, but more about cons Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-26 15:54 +0200
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-27 16:55 +0300
Re: thread about the pros and cons of lambdas, but more about cons Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-26 10:01 -0700
Re: thread about the pros and cons of lambdas, but more about cons Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-26 19:04 +0200
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-26 20:20 +0300
Re: thread about the pros and cons of lambdas, but more about cons Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-26 10:38 -0700
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-27 16:27 +0300
Re: thread about the pros and cons of lambdas, but more about cons Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-28 04:06 -0700
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-26 10:58 +0300
Re: thread about the pros and cons of lambdas, but more about cons Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-26 10:27 -0700
Re: thread about the pros and cons of lambdas, but more about cons Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-26 19:32 +0200
Re: thread about the pros and cons of lambdas, but more about cons Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-26 14:09 -0700
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-27 16:15 +0300
Re: thread about the pros and cons of lambdas, but more about cons Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-28 04:25 -0700
csiph-web