[libcxx-commits] [libcxx] [libc++][ranges] Implement P3052R2: `view_interface::at()` (PR #205012)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Wed Sep 2 00:30:35 PDT 2026


================
@@ -159,6 +161,28 @@ class view_interface {
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](range_difference_t<_RARange> __index) const {
     return ranges::begin(__derived())[__index];
   }
+
+#  if _LIBCPP_STD_VER >= 29
+
+  template <random_access_range _RARange = _Derived>
+    requires sized_range<_RARange> // freestanding-deleted
----------------
frederick-vs-ja wrote:

```suggestion
    requires sized_range<_RARange>
```

The comments seem unhelpful and confusing to me. Now we only support hosted modes (or some proper subsets which still contain hosted components).

If we start supporting freestanding modes, we'll probably write:
```C++
#    if __STDC_HOSTED__ == 1
// current implementation
#    else
  template <random_access_range _RARange = _Derived>
    requires sized_range<_RARange>
  decltype(auto) at(range_difference_t<_RARange>) = delete;

  template <random_access_range _RARange = const _Derived>
    requires sized_range<_RARange>
  decltype(auto) at(range_difference_t<_RARange>) = delete;
#    endif
```

I think we'll all review all `// freestanding-deleted` comments in the working draft at that time, and it's not useful to put them into the product code now.

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


More information about the libcxx-commits mailing list