[libcxx-commits] [libcxx] [libc++] optimization on ranges::drop_view::begin (#72883) (PR #72929)

via libcxx-commits libcxx-commits at lists.llvm.org
Sat Nov 25 00:06:20 PST 2023


================
@@ -90,6 +90,10 @@ namespace ranges {
       requires (!(__simple_view<_View> &&
                   random_access_range<const _View> && sized_range<const _View>))
     {
+      if constexpr (random_access_range<_View> && sized_range<_View>) {
+        range_difference_t<_View> __dist = ranges::distance(__base_);
----------------
huixie90 wrote:

I am fine with both. But I think the spec is describing the behaviour and not necessarily the way one should code. e.g this particular function here the spec is simply describing what the result should be, “Returns” , and one should not use the exact wording for implementation . (I saw you create an LWG issue for this but lots of us think it is not a defect because the spec does not say “equivalent to”)

https://github.com/llvm/llvm-project/pull/72929


More information about the libcxx-commits mailing list