Member |
Description |
pointer_to_binary_function(Result (*f)(Arg1, Arg2)) |
The constructor. Creates a pointer_to_binary_function whose underlying function is f . |
pointer_to_binary_function() |
The default constructor. This creates a pointer_to_binary_function that does not have an underlying function, and that therefore cannot actually be called. |
template pointer_to_unary_function ptr_fun(Result (*x)(Arg1, Arg2)); |
If f is of type Result (*)(Arg1, Arg2) then ptr_fun(f) is equivalent to pointer_to_binary_function(f) , but more convenient. This is a global function, not a member function. |
See also
pointer_to_unary_function , ptr_fun , Adaptable Binary Function
Categories: functors, adaptors
Component type: type
Description
Unary_negate is a function object adaptor: it is an Adaptable Predicate that represents the logical negation of some other Adaptable Predicate. That is: if f is an object of class unary_negate , then there exists an object pred of class AdaptablePredicate such that f(x) always returns the same value as !pred(x) . [1] There is rarely any reason to construct a unary_negate directly; it is almost always easier to use the helper function not1 .
Example
Finds the first element in a list that does not lie in the range from 1 to 10.
list L;
…
list::iterator in_range = find_if(L.begin(), L.end(), not1(compose2(logical_and(), bind2nd(greater_equal(), 1), bind2nd(less_equal(), 10))));
assert(in_range == L.end() || !(*in_range >= 1 && *in_range <= 10));
Definition
Defined in the standard header functional, and in the nonstandard backward-compatibility header function.h.
Template parameters
Parameter |
Description |
AdaptablePredicate |
The type of the function object that this unary_negate is the logical negation of. |
Model of
Adaptable Predicate
Type requirements
AdaptablePredicate must be a model of Adaptable Predicate.
Public base classes
unary_function
Members
Member |
Where defined |
Description |
argument_type |
Adaptable Unary Function |
The type of the argument: AdaptablePredicate::argument_type |
result_type |
Adaptable Unary Function |
The type of the result: bool |
bool operator()(argument_type) |
Unary Function |
Function call operator. |
unary_negate(const AdaptablePredicate& pred) |
unary_negate |
See below. |
template unary_negate not1(const AdaptablePredicate& pred); |
unary_negate |
See below. |
New members
These members are not defined in the Adaptable Predicate requirements, but are specific to unary_negate .
Member |
Description |
unary_negate(const AdaptablePredicate& pred) |
The constructor. Creates a unary_negate whose underlying predicate is pred . |
template unary_negate not1(const AdaptablePredicate& pred); |
If p is of type AdaptablePredicate then not1(p) is equivalent to unary_negate(p) , but more convenient. This is a global function, not a member function. |
Notes
[1] Strictly speaking, unary_negate is redundant. It can be constructed using the function object logical_not and the adaptor unary_compose .
See also
The function object overview, Adaptable Predicate, Predicate, binary_negate , unary_compose , binary_compose
Categories: functors, adaptors
Component type: type
Description
Binary_negate is a function object adaptor: it is an Adaptable Binary Predicate that represents the logical negation of some other Adaptable Binary Predicate . That is: if f is an object of class binary_negate , 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 '\n' .
char str[MAXLEN];
…
const char* wptr = find_if(str, str + MAXLEN, compose2(not2(logical_or()), bind2nd(equal_to(), ' '), bind2nd(equal_to(), '\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 |
AdaptableBinaryPredicate |
The type of the function object that this binary_negate is the logical negation of. |
Model of
Adaptable Binary Predicate
Type requirements
AdaptableBinaryPredicate must be a model of Adaptable Binary Predicate.
Public base classes
binary_function
Members
Member |
Where defined |
Description |
first_argument_type |
Adaptable Binary Function |
The type of the first argument: AdaptableBinaryPredicate::first_argument_type |
second_argument_type |
Adaptable Binary Function |
The type of the second argument: AdaptableBinaryPredicate::second_argument_type |
result_type |
Adaptable Binary Function |
The type of the result: bool |
binary_negate(const AdaptableBinaryPredicate& pred) |
binary_negate |
See below. |
template binary_negate not2(const AdaptableBinaryPredicate& pred); |
binary_negate |
See below. |
New members
These members are not defined in the Adaptable Binary Predicate requirements, but are specific to binary_negate .
Member |
Description |
binary_negate(const AdaptableBinaryPredicate& pred) |
The constructor. Creates a binary_negate whose underlying predicate is pred . |
template binary_negate not2(const AdaptableBinaryPredicate& pred); |
If p is of type AdaptableBinaryPredicate then not2(p) is equivalent to binary_negate(p) , but more convenient. This is a global function, not a member function. |
See also
The function object overview, AdaptablePredicate, Predicate, unary_negate , unary_compose , binary_compose
Читать дальше