(where
Finds the first element in a list that lies in the range from 1 to 10.
list<int> L;
…
list<int>::iterator in_range = find_if(L.begin(), L.end(), compose2(logical_and<bool>(), bind2nd(greater_equal<int>(), 1), bind2nd(less_equal<int>(), 10)));
assert(in_range == L.end() || (*in_range >= 1 && *in_range <= 10));
Defined in the standard header functional, and in the nonstandard backward-compatibility header function.h.
Parameter | Description |
---|---|
T | The type of |
Adaptable Binary Predicate, DefaultConstructible
binary_function<T, T, bool>
Member | Where defined | Description |
---|---|---|
first_argument_type | Adaptable Binary Function | The type of the first argument: |
second_argument_type | Adaptable Binary Function | The type of the second argument: |
result_type | Adaptable Binary Function | The type of the result: |
bool operator()(const T& x, const T& y) const | Binary Function | Function call operator. The return value is |
logical_and() | Default Constructible | The default constructor. |
All of
[1]
The function object overview,
logical_or<T>
Category: functors
Component type: type
Finds the first instance of either ' ' or ' ' in a string.
char str[MAXLEN];
…
const char* wptr = find_if(str, str + MAXLEN, compose2(logical_or<bool>(), bind2nd (equal_to<char>(), ' '), bind2nd(equal_to<char>(), '
')));
assert(wptr == str + MAXLEN || *wptr == ' ' || *wptr == '
');
Defined in the standard header functional, and in the nonstandard backward-compatibility header