[llvm] ADT/Matrix: two-dimensional Container with View (PR #98893)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 15 07:03:05 PDT 2024


artagnon wrote:

> Why would we want to have a dedicated owning (storage) type for 2d arrays? If all you want is to support 2d indexing, I'd imagine something like `std::ndspan` over a plain allocation (e.g., vector) would suffice?
> 
> Also, how is this related to adding `constexpr` to array ref? I understand it's the base PR, but why do we need `constexpr` in the first place?

This is more advanced that `std::mdspan`: it supports variable-length rows, and the immediate use case is to replace the vector-of-vectors idiom. Besides, `std::mdspan` is only available from C++26. Please see #98895 for an example use case.

This is related to adding `constexpr` to ArrayRef, because otherwise, I can't mark anything that depends on ArrayRef functions as `constexpr`.

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


More information about the llvm-commits mailing list