I've started learning C++11 and C++14 and i have a question. Why lambda not returns 23?
template<class T>
auto func(T t)
{
return t;
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
auto abc = []()->auto { return func(23); };
qDebug() << abc; // output: true
return a.exec();
}
You need to actually execute the lambda:
qDebug() << abc();
Currently the <<
overload is converting the type of the lambda to a bool
, and outputting that.