i have have a class with a set of object pointers and i want to save theme in sorted order by their some field(id). for debugging i simplified that to this:
#include<iostream>
#include<set>
using namespace std;
struct c{
auto comp=[](int* i1,int* i2){return *i1>*i2;};
set<int*,decltype(comp)> seti(comp);
};
int main(){}
i searched here to find how to sort them and i select the second approach(because i cant use c++20) when you try to use that in main function or out of a class/structure it works. but i want to use it in my class and i didn't know how to get
auto comp=[](int* i1,int* i2){return *i1>*i2;};
in class.i don't want to using a global lambda.
EDIT:
with constexpr static auto comp=[](int* i1,int* i2){return *i1>*i2;};
compiler get this error:
m.cpp:4:27: error: ‘constexpr const c::<lambda(int*, int*)> c::comp’, declared using local type ‘const c::<lambda(int*, int*)>’, is used but never defined [-fpermissive]
constexpr static auto comp=[](int* i1,int* i2){return *i1>*i2;};