[libcxx-commits] [PATCH] D106923: [libcxx][ranges] Add `views::counted` CPO.

Tim Song via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 29 07:47:54 PDT 2021


tcanens added inline comments.


================
Comment at: libcxx/include/__ranges/counted.h:42
+    _LIBCPP_HIDE_FROM_ABI
+    constexpr auto operator()(_Iter&& __it, iter_difference_t<_Iter> __c) const
+      noexcept(noexcept(
----------------
There are things that are implicitly-but-not-explicitly convertible to `iter_difference_t<_Iter>`, in which case this compiles but the wording calls for rejection.


================
Comment at: libcxx/include/__ranges/counted.h:47
+    {
+      return span(_VSTD::to_address(_VSTD::forward<_Iter>(__it)), static_cast<iter_difference_t<_Iter>>(__c));
+    }
----------------
Why the `static_cast` to the same type?

The forward is also unnecessary - the `to_address` overload for non-pointers should take by const& anyway.


================
Comment at: libcxx/include/__ranges/counted.h:60
+      auto __sent = __it + static_cast<iter_difference_t<_Iter>>(__c);
+      return ranges::subrange(_VSTD::forward<_Iter>(__it), _VSTD::forward<_Iter>(__sent));
+    }
----------------
For `__sent` shouldn't it be a move?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106923



More information about the libcxx-commits mailing list