On Fri, 5 Sept 2025 at 16:26, Jonathan Wakely <jwak...@redhat.com> wrote: > > On Thu, 4 Sept 2025 at 13:22, Luc Grosheintz <luc.groshei...@gmail.com> wrote: > > > > A usecase for P2781R9 is more ergonomic creation of span and mdspan with > > mixed static and dynamic extents, e.g.: > > > > span(ptr, cw<3>) > > extents(cw<3>, 5, cw<7>) > > mdspan(ptr, cw<3>, 5, cw<7>) > > > > should be deduced as: > > span<..., 3> > > extents<..., 3, dyn, 7> > > mdspan<..., extents<..., 3, dyn, 7>> > > > > The change required is to strip cv-qualifiers and references from > > `_Tp::value`, because of: > > > > template<_CwFixedValue _X, typename> > > struct constant_wrapper : _CwOperators > > { > > static constexpr const auto& value = _X._M_data; > > > > libstdc++-v3/ChangeLog: > > > > * include/std/span (__integral_constant_like): Allow the member > > `value` of a constant wrapping type to be a const reference of > > an integer. > > * testsuite/23_containers/mdspan/extents/misc.cc: Add test for > > cw and constant_wrapper. > > * testsuite/23_containers/mdspan/mdspan.cc: Ditto. > > * testsuite/23_containers/span/deduction.cc: Ditto. > > > > Signed-off-by: Luc Grosheintz <luc.groshei...@gmail.com> > > --- > > libstdc++-v3/include/std/span | 3 ++- > > .../23_containers/mdspan/extents/misc.cc | 22 +++++++++++++----- > > .../testsuite/23_containers/mdspan/mdspan.cc | 23 +++++++++++++------ > > .../testsuite/23_containers/span/deduction.cc | 20 +++++++++++++++- > > 4 files changed, 53 insertions(+), 15 deletions(-) > > > > diff --git a/libstdc++-v3/include/std/span b/libstdc++-v3/include/std/span > > index 44f9b36a7ef..f9aa3c77e8e 100644 > > --- a/libstdc++-v3/include/std/span > > +++ b/libstdc++-v3/include/std/span > > @@ -480,7 +480,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > namespace __detail > > { > > template<typename _Tp> > > - concept __integral_constant_like = > > is_integral_v<decltype(_Tp::value)> > > + concept __integral_constant_like = > > + is_integral_v<remove_cvref_t<decltype(_Tp::value)>> > > && !is_same_v<bool, remove_const_t<decltype(_Tp::value)>> > > We also need remove_cvref_t on this line for the not-bool check, so > that constant_wrapper<bool&> doesn't match here, but I haven't opened > an LWG issue about that yet, so we can fix that later.
I've created https://cplusplus.github.io/LWG/issue4351 now.