C++ named requirements: BinaryPredicate
BinaryPredicate is a set of requirements expected by some of the standard library facilities from the user-provided arguments.
Given a BinaryPredicate bin_pred
and a pair of iterators iter1
and iter2
or an iterator iter
and a (possibly const
) value value
, the type and value category of the expression bin_pred(*iter1, *iter2) or, respectively, bin_pred(*iter, value), must meet the BooleanTestable requirements.
In addition, evaluation of that expression is not allowed to call non-const member functions of the dereferenced iterators; syntactically, the predicate must accept const
object arguments, with the same behavior regardless of whether its arguments are const
or non-const
.
[edit] Requirements
- Predicate
- CopyConstructible (unless otherwise specified)
[edit] Standard library
The following standard library facilities expect a BinaryPredicate which isn't a Compare type.
(public member function of
std::forward_list<T,Allocator>
) [edit]
(function template) [edit]
(function template) [edit]
(function template) [edit]
(function template) [edit]
[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 2114 (P2167R3) |
C++98 | convertibility of return types to bool was too weak to reflect the expectation of implementations |
requirements strengthened |
LWG 3031 | C++98 | requirements on const values were insufficent
|
requirements strengthened |