[libcxx-commits] [libcxx] [libc++][ranges] Fix `ranges::join_view` segmented iterator trait (PR #158347)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Thu Sep 18 01:16:22 PDT 2025


================
@@ -255,7 +255,18 @@ struct join_view<_View>::__iterator final : public __join_view_iterator_category
 
   _LIBCPP_HIDE_FROM_ABI constexpr __iterator(_Parent* __parent, _Outer __outer, _Inner __inner)
     requires forward_range<_Base>
-      : __outer_(std::move(__outer)), __inner_(std::move(__inner)), __parent_(__parent) {}
+      : __outer_(std::move(__outer)), __inner_(std::move(__inner)), __parent_(__parent) {
+    auto __get_inner_range = [&]() -> decltype(auto) {
+      if constexpr (__ref_is_glvalue)
+        return *__get_outer();
+      else
+        return *__parent_->__inner_;
+    };
+    if (__inner_ == ranges::end(std::__as_lvalue(__get_inner_range()))) {
+      ++__get_outer();
+      __satisfy();
+    }
+  }
----------------
philnik777 wrote:

It seems very weird to me to have logic inside a constructor that simply initializes the members. IMO it'd be much clear _why we do this logic if it's inside the segmented iterator traits. They should be exactly as complex as they need to be.

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


More information about the libcxx-commits mailing list