Is there a way to make this code compile? I want to have my compare function as a lambda template argument.
#include <iostream>
#include <set>
int main()
{
std::set<int*, [](int *a, int *b){return *a<*b;}> S;
return 0;
}
I am getting the following errors:
prog.cpp: In function ‘int main()’:
prog.cpp:6:17: error: lambda-expression in template-argument
std::set<int*, [](int *a, int *b){return *a<*b;}> S;
^
prog.cpp:6:51: error: template argument 2 is invalid
std::set<int*, [](int *a, int *b){return *a<*b;}> S;
Can anyone please help me to correct the code, or explain why its not possible?
Aucun commentaire:
Enregistrer un commentaire