I am writing a sorting algorithm, that takes a comparison function, similar to
template <class RandomIt, class Compare> void sort(RandomIt first, RandomIt last, Compare comp);
It seems to me that the template parameter
Compare perfectly matches the
Compare named requirement. I am trying to understand how to specify that constraint using C++ 20 concepts, such as
std::equivalence_relation, but I am slightly confused.
If I quote the article on cppreference,
Tsatisfies Compare if
Tsatisfies BinaryPredicate, and Given
comp, an object of type
equiv(a, b), an expression equivalent to
!comp(a, b) && !comp(b, a)
std::strict_weak_ordering could capture my constraints on
comp in the description above, but what about
std::equivalence_relation takes a relation as a first template parameter. What would it be in my sorting function?
Source: Windows Questions C++