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

Hui via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Dec 3 09:55:20 PST 2022


huixie90 added inline comments.


================
Comment at: libcxx/include/__algorithm/lexicographical_compare_three_way.h:45
+  using _Len2   = __iter_diff_t<_InputIterator2>;
+  using _Common = common_type_t<_Len1, _Len2>;
+
----------------
I would Not use `common_type_t` as it might not exist a `common_type` as `common_type` does not work for types that need implicit conversions.
The relevant spec here:
https://eel.is/c++draft/iterator.concept.winc#6.sentence-1
In short, integral types are only "explicitly" convertible to each other, not implicitly.
There are related discussion here: https://github.com/ericniebler/range-v3/issues/1745

I think we want to find which `difference_type` is wider (or we need another type to cover both) and then we need to `static_cast` to that type


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