:
struct LessWithOrder
{
bool operator () (const int& lhs, const int& rhs) {
return lhs != rhs ? lhs < rhs : &lhs < &rhs;
}
};
struct LessWithInvOrder
{
bool operator () (const int& lhs, const int& rhs) {
return lhs != rhs ? lhs < rhs : &lhs > &rhs;
}
};
it = std::min_element(data, data + N, LessWithInvOrder);
it = std::max_element(data, data + N, LessWithOrder);