Here you are not calling descending()
function in your program, you are passing it to std::sort()
as a function pointer which accepts a function pointer of type
bool cmp(const Type1 &a, const Type2 &b);
as its third argument.
according to cppreference , the third argument to std::sort is comp
which is
comparison function object (i.e. an object that satisfies the requirements of Compare) which returns true if the first argument is less than (i.e. is ordered before) the second.
The signature of the comparison function should be equivalent to the following:
bool cmp(const Type1 &a, const Type2 &b);
While the signature does not need to have const &, the function must not modify the objects passed to it and must be able to accept all values of type (possibly const) Type1 and Type2 regardless of value category (thus, Type1 & is not allowed, nor is Type1 unless for Type1 a move is equivalent to a copy (since C++11)).
The types Type1 and Type2 must be such that an object of type RandomIt can be dereferenced and then implicitly converted to both of them.
source :
std::sort