This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Using Lambda with variables in deriving class: Regression or not?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]