stlab.adobe.com Adobe Systems Incorporated

binary_negate

functors.gif
type.gif
adaptors.gif
Categories: functors, adaptors Component type: type

Description

Binary_negate is a functors adaptor: it is an AdaptableBinaryPredicate that represents the logical negation of some other AdaptableBinaryPredicate. That is: if f is an object of class binary_negate<AdaptableBinaryPredicate>, then there exists an object pred of class AdaptableBinaryPredicate such that f(x,y) always returns the same value as !pred(x,y). There is rarely any reason to construct a binary_negate directly; it is almost always easier to use the helper function not2.

Example

Finds the first character in a string that is neither ' ' nor '
'
.

char str[MAXLEN];
...
const char* wptr = find_if(str, str + MAXLEN,
                           compose2(not2(logical_or<bool>()),
                                    bind2nd(equal_to<char>(), ' '),
                                    bind2nd(equal_to<char>(), '\n')));
assert(wptr == str + MAXLEN || !(*wptr == ' ' || *wptr == '\n')); 

Definition

Defined in the standard header functional, and in the nonstandard backward-compatibility header function.h.

Template parameters

Parameter Description Default
AdaptableBinaryPredicate The type of the function object that this binary_negate is the logical negation of.  

Model of

AdaptableBinaryPredicate

Type requirements

AdaptableBinaryPredicate must be a model of AdaptableBinaryPredicate.

Public base classes

binary_function<AdaptableBinaryPredicate::first_argument_type,
                AdaptableBinaryPredicate::second_argument_type,
                bool>

Members

Member Where defined Description
first_argument_type AdaptableBinaryFunction The type of the first argument: AdaptableBinaryPredicate::first_argument_type
second_argument_type AdaptableBinaryFunction The type of the second argument: AdaptableBinaryPredicate::second_argument_type
result_type AdaptableBinaryFunction The type of the result: bool
binary_negate(const AdaptableBinaryPredicate& pred)
binary_negate See below.
template <class AdaptableBinaryPredicate>
binary_negate<AdaptableBinaryPredicate>
not2(const AdaptableBinaryPredicate& pred);
binary_negate See below.

New members

These members are not defined in the AdaptableBinaryPredicate requirements, but are specific to binary_negate.

Member Description
binary_negate(const AdaptableBinaryPredicate& pred)
The constructor. Creates a binary_negate<AdaptableBinaryPredicate> whose underlying predicate is pred.
template <class AdaptableBinaryPredicate>
binary_negate<AdaptableBinaryPredicate>
not2(const AdaptableBinaryPredicate& pred);
If p is of type AdaptableBinaryPredicate then not2(p) is equivalent to binary_negate<AdaptableBinaryPredicate>(p), but more convenient. This is a global function, not a member function.

Notes

See also

The functors, AdaptablePredicate, Predicate, unary_negate, unary_compose, binary_compose

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google