[libcxx] Add mdspan/extents

This patch adds std::extents. extents is one of the core classes used by std::mdspan. It describes a multi-dimensional index space with a mix of compile time and runtime sizes. Furthermore, it is templated on the index type used to describe the multi-dimensional index space.

The class is designed to be highly optimizable in performance critical code sections, and is fully useable in constant expressions contexts.

Testing of this class tends to be somewhat combinatorical, due to the large number of possible corner cases involved in situations where we have both runtime and compile time extents. To add to this, the class is designed to be interoperable (in particular constructible) from arguments which only need to be convertible to the index_type, but are otherwise arbitrary user types. For a larger discussion on the design of this class refer to: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p0009r18.html

Co-authored-by: Damien L-G <dalg24@gmail.com>

Reviewed By: ldionne, #libc

Spies: libcxx-commits, H-G-Hristov, tschuett, philnik, arichardson, Mordante, crtrott

Differential Revision: https://reviews.llvm.org/D148067
This commit is contained in:
Christian Trott
2023-05-16 12:38:11 -07:00
committed by Nikolas Klauser
parent 02a029f7fb
commit fcaccf817d
44 changed files with 2220 additions and 287 deletions

View File

@@ -1162,6 +1162,16 @@ module std [system] {
export initializer_list
export *
}
module mdspan {
header "mdspan"
export array
export span
export *
module __mdspan {
module extents { private header "__mdspan/extents.h" }
}
}
module memory {
header "memory"
export *