Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #47468 > unrolled thread

lamda's in classes

Started byruben safir <ruben@mrbrklyn.com>
First post2016-12-21 04:09 -0500
Last post2016-12-21 15:45 -0800
Articles 3 — 3 participants

Back to article view | Back to comp.lang.c++


Contents

  lamda's in classes ruben safir <ruben@mrbrklyn.com> - 2016-12-21 04:09 -0500
    Re: lamda's in classes "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2016-12-21 13:27 +0100
      Re: lamda's in classes jonkalb@boost.org - 2016-12-21 15:45 -0800

#47468 — lamda's in classes

Fromruben safir <ruben@mrbrklyn.com>
Date2016-12-21 04:09 -0500
Subjectlamda's in classes
Message-ID<o3dgsv$cas$1@reader1.panix.com>
if you make a lamda with a method from a class, can that method see the
valuable values encapsulated with the object of that class, or can it
only see global variables?

[toc] | [next] | [standalone]


#47471

From"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>
Date2016-12-21 13:27 +0100
Message-ID<o3dsdt$n2n$1@dont-email.me>
In reply to#47468
On 21.12.2016 10:09, ruben safir wrote:
> if you make a lamda with a method from a class, can that method see the
> valuable values encapsulated with the object of that class, or can it
> only see global variables?
>

To use non-static data members in a lambda in a class' code, you have to 
capture `this`.

Cheers & hth.,

- Alf

[toc] | [prev] | [next] | [standalone]


#47497

Fromjonkalb@boost.org
Date2016-12-21 15:45 -0800
Message-ID<8cfb9dad-1fb1-42dc-a567-7a3c6061d032@googlegroups.com>
In reply to#47471
On Wednesday, December 21, 2016 at 4:28:13 AM UTC-8, Alf P. Steinbach wrote:
> On 21.12.2016 10:09, ruben safir wrote:
> > if you make a lamda with a method from a class, can that method see the
> > valuable values encapsulated with the object of that class, or can it
> > only see global variables?
> >
> 
> To use non-static data members in a lambda in a class' code, you have to 
> capture `this`.
> 
> Cheers & hth.,
> 
> - Alf

Alf,

I want to congratulation you on understanding the question. Seeing your answer, I think you figured out the question and answered it correctly.

When I read the question, I had no idea what was being asked. I think the "valuable values" threw me most.

Jon

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c++


csiph-web