std::not2 is implemented in the following way:
template <class Predicate>
binary_negate<Predicate> not2 (const Predicate& pred)
{
return binary_negate<Predicate>(pred);
}
It uses std::binary_negate in its implementation and binary_negate which is inherited from std::binary_function requires _Predicate::first_argument_type and _Predicate::second_argument_type in its templated arguments in the following way:
template <class _Predicate>
class binary_negate : public binary_function<typename _Predicate::first_argument_type,
typename _Predicate::second_argument_type,
bool>
{
// ...
}
And my question is why I can write something like this if there are no typedefs for first_argument_type and second_argument_type in the Predicate that I am passing?
struct new_same
{
bool operator()(int a, int b) const { return a == b; }
};
auto not_same = std::not2(std::function<bool(int, int)>(new_same()));