Skip to content

[LWG motion 18] P3029R1 Better mdspan's CTAD #6907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions source/containers.tex
Original file line number Diff line number Diff line change
Expand Up @@ -18228,6 +18228,20 @@
// constants
inline constexpr size_t @\libglobal{dynamic_extent}@ = numeric_limits<size_t>::max();

template<class T>
concept @\defexposconcept{integral-constant-like}@ = // \expos
is_integral_v<decltype(T::value)> &&
!is_same_v<bool, remove_const_t<decltype(T::value)>> &&
@\libconcept{convertible_to}@<T, decltype(T::value)> &&
@\libconcept{equality_comparable_with}@<T, decltype(T::value)> &&
bool_constant<T() == T::value>::value &&
bool_constant<static_cast<decltype(T::value)>(T()) == T::value>::value;

template<class T>
constexpr size_t @\defexposconcept{maybe-static-ext}@ = dynamic_extent; // \expos
template<@\exposconcept{integral-constant-like}@ T>
constexpr size_t @\exposconcept{maybe-static-ext}@<T> = {T::value};

// \ref{views.span}, class template \tcode{span}
template<class ElementType, size_t Extent = dynamic_extent>
class span; // partially freestanding
Expand Down Expand Up @@ -18343,7 +18357,8 @@
};

template<class It, class EndOrSize>
span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>,
@\exposconcept{maybe-static-ext}@<EndOrSize>>;
template<class T, size_t N>
span(T (&)[N]) -> span<T, N>;
template<class T, size_t N>
Expand Down Expand Up @@ -18635,7 +18650,8 @@
\indexlibrary{\idxcode{span}!deduction guide}%
\begin{itemdecl}
template<class It, class EndOrSize>
span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>,
@\exposconcept{maybe-static-ext}@<EndOrSize>>;
\end{itemdecl}

\begin{itemdescr}
Expand Down Expand Up @@ -19098,15 +19114,6 @@
const mdspan<ElementType, Extents, LayoutPolicy, AccessorPolicy>& src,
SliceSpecifiers... slices) -> @\seebelow@;

template<class T>
concept @\defexposconcept{integral-constant-like}@ = // \expos
is_integral_v<decltype(T::value)> &&
!is_same_v<bool, remove_const_t<decltype(T::value)>> &&
@\libconcept{convertible_to}@<T, decltype(T::value)> &&
@\libconcept{equality_comparable_with}@<T, decltype(T::value)> &&
bool_constant<T() == T::value>::value &&
bool_constant<static_cast<decltype(T::value)>(T()) == T::value>::value;

template<class T, class IndexType>
concept @\defexposconcept{index-pair-like}@ = // \expos
@\exposconcept{pair-like}@<T> &&
Expand Down Expand Up @@ -19458,7 +19465,7 @@

\pnum
\remarks
The deduced type is \tcode{dextents<size_t, sizeof...(Integrals)>}.
The deduced type is \tcode{extents<size_t, \exposconcept{maybe-static-ext}<Integrals>...>}.
\end{itemdescr}

\rSec4[mdspan.extents.obs]{Observers of the multidimensional index space}
Expand Down Expand Up @@ -22549,7 +22556,7 @@
template<class ElementType, class... Integrals>
requires ((is_convertible_v<Integrals, size_t> && ...) && sizeof...(Integrals) > 0)
explicit mdspan(ElementType*, Integrals...)
-> mdspan<ElementType, dextents<size_t, sizeof...(Integrals)>>;
-> mdspan<ElementType, extents<size_t, @\exposconcept{maybe-static-ext}@<Integrals>...>>;

template<class ElementType, class OtherIndexType, size_t N>
mdspan(ElementType*, span<OtherIndexType, N>)
Expand Down