static bool four_iter_impl()

in include/range/v3/algorithm/permutation.hpp [57:102]


            static bool four_iter_impl(I1 begin1, S1 end1, I2 begin2, S2 end2, C pred_, P1 proj1_,
                P2 proj2_)
            {
                auto &&pred = as_function(pred_);
                auto &&proj1 = as_function(proj1_);
                auto &&proj2 = as_function(proj2_);
                // shorten sequences as much as possible by lopping off any equal parts
                for(; begin1 != end1 && begin2 != end2; ++begin1, ++begin2)
                    if(!pred(proj1(*begin1), proj2(*begin2)))
                        goto not_done;
                return begin1 == end1 && begin2 == end2;
            not_done:
                // begin1 != end1 && begin2 != end2 && *begin1 != *begin2
                auto l1 = distance(begin1, end1);
                auto l2 = distance(begin2, end2);
                if(l1 != l2)
                    return false;

                // For each element in [f1, l1) see if there are the same number of
                //    equal elements in [f2, l2)
                for(I1 i = begin1; i != end1; ++i)
                {
                    // Have we already counted the number of *i in [f1, l1)?
                    for(I1 j = begin1; j != i; ++j)
                        if(pred(proj1(*j), proj1(*i)))
                            goto next_iter;
                    {
                        // Count number of *i in [f2, l2)
                        iterator_difference_t<I2> c2 = 0;
                        for(I2 j = begin2; j != end2; ++j)
                            if(pred(proj1(*i), proj2(*j)))
                                ++c2;
                        if(c2 == 0)
                            return false;
                        // Count number of *i in [i, l1) (we can start with 1)
                        iterator_difference_t<I1> c1 = 1;
                        for(I1 j = next(i); j != end1; ++j)
                            if(pred(proj1(*i), proj1(*j)))
                                ++c1;
                        if(c1 != c2)
                            return false;
                    }
            next_iter:;
                }
                return true;
            }