Negators

unary_negate Unary Predicate
binary_negate Binary Predicate

unary_negate<Predicate> not1 (const Predicate& pred) Function
binary_negate<Predicate> not2 (const Predicate& pred) Function

Negators not1 and not2 take a unary and a binary predicate correspondingly and return their complements.


template 
class unary_negate : public unary_function {
protected:
    Predicate pred;

public:
    unary_negate(const Predicate& x) : pred(x) {}
    bool operator()(const argument_type& x) const { return !pred(x); }
};

template 
unary_negate not1(const Predicate& pred) {
    return unary_negate(pred);
}

template 
class binary_negate
: public binary_function {
protected:
    Predicate pred; public:
    binary_negate(const Predicate& x) : pred(x) {}
    bool operator()(const first_argument_type& x,
                    const second_argument_type& y) const {
        return !pred(x, y);
    }
};

template 
binary_negate not2(const Predicate& pred) {
    return binary_negate(pred);
}