static I1 impl()

in include/range/v3/algorithm/search.hpp [92:121]


            static I1 impl(I1 begin1, S1 end1, I2 begin2, S2 end2, C &pred, P1 &proj1, P2 &proj2)
            {
                while(true)
                {
                    // Find begin element in sequence 1 that matches *begin2, with a mininum of loop checks
                    while(true)
                    {
                        if(begin1 == end1)  // return end1 if no element matches *begin2
                            return begin1;
                        if(pred(proj1(*begin1), proj2(*begin2)))
                            break;
                        ++begin1;
                    }
                    // *begin1 matches *begin2, now match elements after here
                    I1 m1 = begin1;
                    I2 m2 = begin2;
                    while(true)
                    {
                        if(++m2 == end2)  // If pattern exhausted, begin1 is the answer (works for 1 element pattern)
                            return begin1;
                        if(++m1 == end1)  // Otherwise if source exhausted, pattern not found
                            return m1;
                        if(!pred(proj1(*m1), proj2(*m2)))  // if there is a mismatch, restart with a new begin1
                        {
                            ++begin1;
                            break;
                        }  // else there is a match, check next elements
                    }
                }
            }