Predicate with argument

C

Christopher

How do I use std::find_if with a predicate that takes an argument?

For example,
If I have a vector of pointers to classes that contain ints
I want to search for the first occurence a class containing, the
number 7
Later, I want to search for the first occurence of a class in the same
vector, containg the numer 5
Where the number is the argument I want to pass to the predicate

In my real code the argument is a string
The vector contains smart pointers to classes that contain a string
amongst other things.

I am searching for the first occurence that have one string
Then I am changing the string and searching.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top