Skip to content

Latest commit

 

History

History
21 lines (18 loc) · 603 Bytes

find_if.md

File metadata and controls

21 lines (18 loc) · 603 Bytes

find_if

Description : Returns the first element in the range [first, last) that satisfies specific criteria(searches for an element for which predicate/condition p returns true).

Example:

    bool IsOdd (int i) {
        return ((i%2)==1);
    }

    int main(){
        std::vector<int> v{ 1, 2, 3, 4, 4, 3, 7, 8, 9, 10 };
        if(std::find_if(std::begin(v), std::end(v), IsOdd) != std::end(v)){
            std::cout <<"\n Odd Value Found";
        }
        else
            std::cout<<"No match !!";
        return 0;
    }

Run Code