This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Using Lambda with variables in deriving class: Regression or not?
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Deniz Sarikaya <daimler3 at googlemail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 17 Feb 2012 12:06:12 +0000
- Subject: Re: Using Lambda with variables in deriving class: Regression or not?
- References: <CAHN6VueidURvtamHUJQgc9+QCgsPJTTtSiTkXbOuMMBF2OQi7w@mail.gmail.com> <CAHN6VueZ-GP+MPTd0-xS1YPkJwm3k9-O3AMrbHbJWVe1Oec9VA@mail.gmail.com>
On 17 February 2012 10:30, Deniz Sarikaya wrote:
>
> As a workaround I turned
>
> [&variable]() -> void
> {
> ??? variable->memfunc();
> }
>
> to
>
> [&]() -> void
> {
> ??? variable->memfunc();
> }
>
>
> Did I do something wrong or why is this not working anymore?
I'm guessing the problem has nothing to do with derived classes, it's
that identifiers in the capture-list must be local variables or 'this'
so to capture a member you must capture 'this'
So you probably want:
[this]() -> void
{
variable->memfunc();
}
GCC 4.6 accepted incalid captures but that was probably changed by the
fix for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50736