http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46048
Summary: lambda: access to a member function
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
In GCC 4.5.0 the follwing class fails to compile. In C++0x draft n3126, the
member variable 'f' does not require 'this->'. Surely the same should apply to
a member function.
struct S10
{
int f;
double p;
void inc(int& a) { a += f;}
void work(int n)
{
int m = n*n;
int j = 40;
f = 10;
p =3.7;
auto m3 = [this,&n]() mutable -> int
{
p++;
f++;
this->inc(n); //required
return n;
};
cout << "S9 m3():" << m3() << endl;
cout << "f:" << f << " p:" << p << " n:" << n << endl;
}
};