I have a map container. How to return the first value greater than the user-specified search value by using find_if as follows:
std::map<string, int>::iterator it = find_if(Mymap.begin(), Mymap.end(), ......
Thank you very much!
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.
With a lambda:
(If the value is fixed you can put it directly inside the lambda body. For C++14 and later, the lambda capture can be
[n = MYVALUE]and you don’t need a separate outer variablen.)With a predicate: