]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Better CTAD for span and mdspan [PR120914].
authorLuc Grosheintz <luc.grosheintz@gmail.com>
Tue, 8 Jul 2025 09:49:21 +0000 (11:49 +0200)
committerTomasz Kamiński <tkaminsk@redhat.com>
Tue, 8 Jul 2025 14:48:46 +0000 (16:48 +0200)
commit9c600a7e6cc588d2ee79d764cbf69ad677b1bac5
treeef5012f51b4ef57a66ee2681dc23e15c1c0a5af2
parentbb6075e7115208bab3d9c8b2c54e0bd6a5c808b7
libstdc++: Better CTAD for span and mdspan [PR120914].

This implements P3029R1. In P3029R1, the CTAD for span is refined to
permit deducing the extent of the span from an integral constant, e.g.

  span((T*) ptr, integral_constant<size_t, 5>{});

is deduced as span<T, 5>. Similarly, in

  auto exts = extents(integral_constant<int, 2>);
  auto md = mdspan((T*) ptr, integral_constant<int, 2>);

exts and md have types extents<size_t, 2> and mdspan<double,
extents<size_t, 2>>, respectively.

PR libstdc++/120914

libstdc++-v3/ChangeLog:

* include/std/span (span): Update CTAD to enable
integral constants [P3029R1].
* include/std/mdspan (extents): ditto.
(mdspan): ditto.
* testsuite/23_containers/span/deduction.cc: Test deduction
guide.
* testsuite/23_containers/mdspan/extents/misc.cc: ditto.
* testsuite/23_containers/mdspan/mdspan.cc: ditto.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
libstdc++-v3/include/std/mdspan
libstdc++-v3/include/std/span
libstdc++-v3/testsuite/23_containers/mdspan/extents/misc.cc
libstdc++-v3/testsuite/23_containers/mdspan/mdspan.cc
libstdc++-v3/testsuite/23_containers/span/deduction.cc