#include
#include
using namespace std;
Bool CMP (int a, int b)
{
Return a & lt; b;
}
Int main (int arg c, char * argv [])
{
QCoreApplication a (arg c, argv);
Vector
Vector
Cout & lt; <"Lbvec: \ n";
For (int it: lbvec)
Cout & lt;
Sort (equivalent. The begin (), equivalent. The end (), CMP);//the old practice
Cout & lt; <"Predicate function:" & lt;
Cout & lt;
Sort (lbvec. The begin (), lbvec end (), [] (int a, int b) - & gt; Bool {return a & lt; b; });//Lambda expressions
Cout & lt; <"The lambda expression:" & lt;
Cout & lt;
Return a.e xec ();
}
The output is:
Lbvec:
3 2 5 7 3 2
Predicate function:
2, 2, 3, 3 5 7
Lambda expression:
Obviously no anonymous function called! The environment is ubuntu18.04 qtcreator4.11 g + + 9.3.0
Know the cause of the trouble to give directions!
CodePudding user response:
Try [=]CodePudding user response:
Your code can be estimated is the output reason qt start blockingCodePudding user response:
Turned out to be a.e xec () to blame!