[libcxx-commits] [PATCH] D131395: [libc++] Implement `lexicographical_compare_three_way`

Kent Ross via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Aug 10 22:36:17 PDT 2022


mumbleskates added a comment.

I think the random access iterator optimization is probably pretty important here. it may be doable to eventually derive this optimization from very simple iterator types like `int*`, but there are plenty of examples of very non-trivial iterator types where this may not be the case. iterators over order-statistic trees can satisfy every requirement of `random_access_iterator` while being somewhat complex.

put another way, it seems like `random_access_iterator` is the minimum bar for an iterator whose difference is constant time. is it correct to say that the true number of elements in `random_access_iterator` ranges must compare to each other equivalently to the iterator_difference values of each range's end - begin? if that is the case then we can know that one iterator is not longer than the other, bound the whole iteration upon it, and know what to do if it is exhausted.

in any event it seems very likely to me that there is some point at which an optimization like this will be desirable, more likely than that we can get away without it forever.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131395/new/

https://reviews.llvm.org/D131395



More information about the libcxx-commits mailing list