Is it possible to pass a pointer to an operator as an argument like a pointer to a function?

You cannot obtain a pointer to a built-in operator. But fortunately, the standard library provides function objects for all standard operators. In your case, that object’s name is std::greater:

sort (arr, arr + N, std::greater<int>{});

Since C++14, you can even omit the argument type and it will be deduced from how the object is used:

sort (arr, arr + N, std::greater<>{});

And since C++17, the empty <> can be omitted too:

sort (arr, arr + N, std::greater{});

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)