[Bug c++/48523] New: [C++0x] lambda cannot capture 'this' in class template

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Apr 8 22:26:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48523

           Summary: [C++0x] lambda cannot capture 'this' in class template
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: redi@gcc.gnu.org
                CC: jason@gcc.gnu.org


template<typename>
struct X
{
  bool b;

  void f()
  {
    [this]{ return b; };
  }
};

X<int> x;

l.cc: In lambda function:
l.cc:8:20: error: invalid type argument (have ‘decltype (this)’)

The same lambda works fine in a non-template class



More information about the Gcc-bugs mailing list