[libcxx-commits] [PATCH] D80902: [libcxx] adds lexicographical_compare_three_way

Michael Schellenberger Costa via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun May 31 23:57:33 PDT 2020


miscco added inline comments.


================
Comment at: libcxx/include/algorithm:5633
+    for (; __first1 != __last1 && __first2 != __last2; void(++__first1), void(++__first2))
+    if (auto __cmp = __comp(*__first1, *__first2); __cmp != 0)
+        return __cmp;
----------------
The identation here is off. Could you please add braces so that it is clear where the loop ends


================
Comment at: libcxx/test/std/algorithms/alg.sorting/alg.three.way/lexicographical_compare_three_way.pass.cpp:40
+    int ib[] = {1, 2, 3};
+    assert(std::lexicographical_compare_three_way(Iter1(ia),   Iter1(ia+sa), Iter2(ib),   Iter2(ib+2)) == std::strong_ordering::greater);
+    assert(std::lexicographical_compare_three_way(Iter1(ib),   Iter1(ib+2),  Iter2(ia),   Iter2(ia+sa)) == std::strong_ordering::less);
----------------
These are rather subtle tests. To make it imediately clear what you are actually testing I would appreciate if you could go the extra mile and add comments

// lexicographical_compare_three_way(a, b),  range b shorter than range a

// lexicographical_compare_three_way(a, b),  range a shorter than range b


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D80902





More information about the libcxx-commits mailing list