0
Set in descending order or with > overloaded operator
I have a class for C++ and it needed to sort in decending order So, I provided now > operator overloading and sort works with greater<>() functor. Default sort works only if I provide < operator overloading for class Now, Is there a provision for me to have set without providing < operator? Can we do something while creating set object which does not demand < operator for class and work with > operator? Compiler will throw error if I will remove < opeartor overloading in attached code https://sololearn.com/compiler-playground/cE5smx6LGeKH/?ref=app
2 Respuestas
0
no. you need at least an overload of <
you can do away with > overload if you want descending sort by using rbegin() and rend() though...
https://sololearn.com/compiler-playground/c25lnxyJfIrX/?ref=app
0
Yes, rbegin is there but I am not much concerned about what else class has.
I am just curious to know whether > would work for any of the provision for set ?