[libcxx-commits] [libcxx] [libc++][mdspan] P3383R3: mdspan.at() (PR #175213)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jan 12 00:40:44 PST 2026
================
@@ -213,6 +214,37 @@ class mdspan {
}(make_index_sequence<rank()>()));
}
+# if _LIBCPP_STD_VER >= 26
+ template <class... _OtherIndexTypes>
+ requires((is_convertible_v<_OtherIndexTypes, index_type> && ...) &&
+ (is_nothrow_constructible_v<index_type, _OtherIndexTypes> && ...) &&
+ (sizeof...(_OtherIndexTypes) == rank()))
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference at(_OtherIndexTypes... __indices) const {
+ if (!__mdspan_detail::__is_multidimensional_index_in(__map_.extents(), __indices...)) {
+ __throw_out_of_range();
+ }
+ return operator[](static_cast<index_type>(std::move(__indices))...);
----------------
philnik777 wrote:
```suggestion
return (*this)[static_cast<index_type>(std::move(__indices))...];
```
https://github.com/llvm/llvm-project/pull/175213
More information about the libcxx-commits
mailing list