C++ concepts: Predicate

The Predicate concept describes a function object that takes a single iterator argument that is dereferenced and used to return a value testable as a bool.

In other words, if an algorithm takes a Predicate pred and an iterator first, it should be able to test the iterator using the predicate via a construct like if (pred(*first)) {...}.

The function object pred shall not apply any non-constant function through the dereferenced iterator. This function object may be a pointer to function or an object of a type with an appropriate function call operator.


© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.