The Predicate requirements describe a callable that returns a BooleanTestable value.
Predicate is typically used with algorithms that take input data (individual objects/containers) and a predicate, which is then called on input data to decide on further course of action. Some examples of predicate usage in C++ standard library are:
Description of algorithm facilities, given above, is crude and intended to explain Predicate in simple terms. For detailed info, refer to individual pages.
In other words, if an algorithm takes a Predicate pred
and an iterator first
, it should be able to test the object of the type pointed to by the iterator first
using the given predicate via a construct like if (pred(*first)) { /*...*/ }.
The function object pred
shall not apply any non-constant function through the dereferenced iterator and must accept a const
argument, with the same behavior regardless of whether the argument is const
or non-const
. This function object may be a pointer to function or an object of a type with an appropriate function call operator.
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior LWG 3031 C++98 requirements onconst
values were insufficent requirements strengthened [edit] See also specifies that a callable type is a Boolean predicate
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4