There seems to be an issue with using a member function when i want to create a custom compare for the std::list function sort. I'm getting the following errors:
Error C3867 'my_class::cmp': non - standard syntax; use '&' to create a pointer to member
Error C2660 'std::list>::sort': function does not take 1 arguments
Below is the code to reproduce the error
#include <list>
class my_class {
std::list<int> container;
public:
bool cmp(const int& a, const int& b) {
return a < b;
}
void push(int e) {
container.push_back(e);
container.sort(cmp);
}
};
int main()
{
my_class my_c;
return 0;
}
Not really sure why im getting the errors. If i do this outside a class it works just fine.