On 06/03/20 07:06 +0100, François Dumont wrote:
I started to work on ranges::equal to find out if what I am trying to do is totally silly.

With this patch ranges::equal is in pare with std::equal specializations that is to say that it correctly deals with Debug mode or std::deque iterators.

Once below patch is in:

https://gcc.gnu.org/ml/libstdc++/2019-12/msg00032.html

We will even be able to call std::__equal_aux1 directly using __niter_base to get rid of the Debug safe iterator layer. And even in this case get rid of the branch __use_memcmp and leave it to __equal_aux1.

I mainly fear the usage of std::iterator_traits in __equal_aux1 to be a problem. Is it in this context of sized_sentinel ?

I don't understand the question. No sentinel of type _Sent1 or _Sent2
gets passed to __equal_aux1 with your patch, you only pass iterators.

But I think the patch is wrong:

+                 return !std::__memcmp(__first1, __first2, __d1);
+               else
+                 return std::__equal_aux(__first1, __first1 + __d1, __first2);

This last line will only compile if _Iter1 is random access, but all
we know at this point is that _Sent1 is a sized sentinel for _Iter1.
That doesn't mean it's necessarily random access.

Reply via email to