I last used C++ in 2003, and am trying to revisit, and learn the new stuff. Have been working in Java for a while, and just learning its Lambda syntax. Saw this example in C++, and wondering if someone could explain it:
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int i = 42;
char code = 'c';
[=, &i]() mutable
{
i++;
code = 'd';
std::cout << "i: " << i << "code " << code << std::endl;
}();
void wait()
{
cin.clear();
cin.ignore();
cin.get();
}
int main()
{
std::cout << "i: " << i << "code " << code << endl;
// hold output window open
wait();
return 0;
}
Is this new lambda syntax for operator= overload? I'd write a test function, but am not sure how to invoke it.