Closed ChaiByte closed 1 year ago
I agree that there's room for optimizations here in the case of random access iterators, but this implementation is not the right one for iterators which are not random access.
This optimization needs to branch behaviour when the iterator is random access vs when it isn't. EASTL doesn't yet require C++17 to compile so at this point this should probably be done with tagged dispatch (similar to what we do with eastl::distance
) or with a "normal-not-constexpr" if on a compile time constant check, as opposed to using if constexpr
, which would be the way to do this in C++17.
I'll close this PR temporarily until we find a better solution.
As described in https://github.com/electronicarts/EASTL/pull/514#discussion_r1255556282 , It's a X-Y problem when discussing the correct method fixing ring buffer comparation operator. Another issue to become evident.
Current
eastl::identical
is not effient enough when input iterators meet LegacyRandomAccessIterator requirements.Refs: https://en.cppreference.com/w/cpp/algorithm/equal
By the way, I want to know why did EASTL choose to implement the
equal
andidentical
interfaces separately at the beginning of the design, is there any reference to explain the reason?