0

I've been having issues compiling some code from a library due to a particular line,

std::sort(indices.begin(), indices.end(), [this](size_t i1, size_t i2) {return (*this)[i1] < (*this)[i2];});

The error thrown is:

 expected expression            

Referring specifically to the first bracket around "this." I've never seen "this" used in this format before. Does this technically work, and if so, how? The function used is the standard sort function, so there should be a function pointer where this appears instead.

Thanks!

Baum mit Augen
  • 46,177
  • 22
  • 136
  • 173

0 Answers0