Can somebody explain to me how is the pred field in stl algorithms exactly used?
Thank you
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
predstands for predicate which is basically a callable entity which is either a function, or a functor (or a lambda, which is essentially a functor or function depending on whether it captures variable(s) or not). So a predicate may take one or more argument(s), and returns a boolean value.Here is an example of std::find_if, one overload of which takes unary predicate as third argument. This predicate is unary because it takes one argument and returns
bool:Notice the third argument is a lambda which is used as unary predicate.
In C++03, the example can be this:
Note that now
is_threewhich is a function is passed as third argument tostd::find_if.