I am trying to change the order of a set in a particular configuration :
a customObject has the following form
class CustomObject{
public:
...
std::set<CustomObject*> container;
};
and I would like to keep permanently the property telling that the container is sorted in the following order :
elt1
& elt2
are elements of container,
and
elt1 < elt2
iff elt1.container.size()<elt2.container.size()
I know I have to use
struct cmpStruct {
bool operator() (int const & lhs, int const & rhs) const
{
return lhs > rhs;
}
};
as described Is the std::set iteration order always ascending according to the C++ specification?
But I don't know how to do to access the "this" inside the structure
Thanks a lot for your help