I have a vector std::vector. I would like to iterate the vector for finding a match, if found would like to return the pointer to the element as below:
const int * findint(std::vector <int> &v, int a)
{
        std::vector<int>::const_iterator i1,i2;
        i1 = v.begin();
        i2 = v.end();
        for(;i1 != i2;++i1) {
                if(a== *i1) {
                        return(i1);
                }
        }
        return(0);
}
This was compiling and working ok with GNU g++2.95.3 compiler but not compiling with GNU g++ 4.9.2 and giving the following error:
error: cannot convert 'std::vector<GenFld>::const_iterator {aka __gnu_cxx::__normal_iterator<const int*, std::vector<int> >}' to 'const int*' in return
     [exec]     return(i1);
Need help.
 
     
     
     
    