[libcxx-commits] [PATCH] D156956: [libc++] Optimize ranges::count for __bit_iterators

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Sep 28 09:31:24 PDT 2023


ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

LGTM with comments applied and CI passing.



================
Comment at: libcxx/include/__algorithm/count.h:46
+template <bool _ToCount, class _Cp, bool _IsConst>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __bit_iterator<_Cp, _IsConst>::difference_type
+__count_bool(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) {
----------------
And we should make sure that we have a test for that, i.e. call `std::count(bit-iterator)` and `ranges::count(bit-iterator)` in constexpr in C++20 mode.


================
Comment at: libcxx/include/__algorithm/iterator_operations.h:176-177
 
+template <class _AlgPolicy, class _Iter>
+using __policy_diff_t = typename _IterOps<_AlgPolicy>::template __difference_type<_Iter>;
+
----------------
ldionne wrote:
> I think I would avoid introducing this, I don't think it provides that much value.
^

I wouldn't necessarily object to introducing these types, but we should do that separately and handle not only `__difference_type`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156956



More information about the libcxx-commits mailing list