Skip to content

Commit aba6104

Browse files
authored
Merge 2025-06 LWG Motion 14
P3383R3 mdspan.at()
2 parents f269c02 + 7b3b02c commit aba6104

File tree

1 file changed

+73
-2
lines changed

1 file changed

+73
-2
lines changed

source/containers.tex

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21034,7 +21034,7 @@
2103421034

2103521035
\indexheader{mdspan}%
2103621036
\begin{codeblock}
21037-
// all freestanding
21037+
// mostly freestanding
2103821038
namespace std {
2103921039
// \ref{mdspan.extents}, class template \tcode{extents}
2104021040
template<class IndexType, size_t... Extents>
@@ -21068,7 +21068,7 @@
2106821068
// \ref{mdspan.mdspan}, class template \tcode{mdspan}
2106921069
template<class ElementType, class Extents, class LayoutPolicy = layout_right,
2107021070
class AccessorPolicy = default_accessor<ElementType>>
21071-
class mdspan;
21071+
class mdspan; // partially freestanding
2107221072

2107321073
// \ref{mdspan.sub}, \tcode{submdspan} creation
2107421074
template<class OffsetType, class LengthType, class StrideType>
@@ -24698,6 +24698,16 @@
2469824698
template<class OtherIndexType>
2469924699
constexpr reference operator[](const array<OtherIndexType, rank()>& indices) const;
2470024700

24701+
template<class... OtherIndexTypes>
24702+
constexpr reference
24703+
at(OtherIndexTypes... indices) const; // freestanding-deleted
24704+
template<class OtherIndexType>
24705+
constexpr reference
24706+
at(span<OtherIndexType, rank()> indices) const; // freestanding-deleted
24707+
template<class OtherIndexType>
24708+
constexpr reference
24709+
at(const array<OtherIndexType, rank()>& indices) const; // freestanding-deleted
24710+
2470124711
constexpr size_type size() const noexcept;
2470224712
constexpr bool empty() const noexcept;
2470324713

@@ -25146,6 +25156,67 @@
2514625156
\end{codeblock}
2514725157
\end{itemdescr}
2514825158

25159+
\indexlibrarymember{at}{mdspan}%
25160+
\begin{itemdecl}
25161+
template<class... OtherIndexTypes>
25162+
constexpr reference at(OtherIndexTypes... indices) const;
25163+
\end{itemdecl}
25164+
25165+
\begin{itemdescr}
25166+
\pnum
25167+
\constraints
25168+
\begin{itemize}
25169+
\item
25170+
\tcode{(is_convertible_v<OtherIndexTypes, index_type> \&\& ...)} is \tcode{true},
25171+
\item
25172+
\tcode{(is_nothrow_constructible_v<index_type, OtherIndexTypes> \&\& ...)} is \tcode{true}, and
25173+
\item
25174+
\tcode{sizeof...(OtherIndexTypes) == rank()} is \tcode{true}.
25175+
\end{itemize}
25176+
25177+
\pnum
25178+
Let \tcode{I} be \tcode{extents_type::\exposid{index-cast}(std::move(indices))}.
25179+
25180+
\pnum
25181+
\returns
25182+
\tcode{(*this)[I...]}.
25183+
25184+
\pnum
25185+
\throws
25186+
\tcode{out_of_range} if \tcode{I} is not a multidimensional index in \tcode{extents()}.
25187+
\end{itemdescr}
25188+
25189+
\indexlibrarymember{at}{mdspan}%
25190+
\begin{itemdecl}
25191+
template<class OtherIndexType>
25192+
constexpr reference at(span<OtherIndexType, rank()> indices) const;
25193+
template<class OtherIndexType>
25194+
constexpr reference at(const array<OtherIndexType, rank()>& indices) const;
25195+
\end{itemdecl}
25196+
25197+
\begin{itemdescr}
25198+
\pnum
25199+
\constraints
25200+
\begin{itemize}
25201+
\item
25202+
\tcode{is_convertible_v<const OtherIndexType\&, index_type>} is \tcode{true}, and
25203+
\item
25204+
\tcode{is_nothrow_constructible_v<index_type, const OtherIndexType\&>} is \tcode{true}.
25205+
\end{itemize}
25206+
25207+
\pnum
25208+
\effects
25209+
Let \tcode{P} be a parameter pack such that
25210+
\begin{codeblock}
25211+
is_same_v<make_index_sequence<rank()>, index_sequence<P...>>
25212+
\end{codeblock}
25213+
is \tcode{true}.
25214+
Equivalent to:
25215+
\begin{codeblock}
25216+
return at(extents_type::@\exposid{index-cast}@(as_const(indices[P]))...);
25217+
\end{codeblock}
25218+
\end{itemdescr}
25219+
2514925220
\indexlibrarymember{size}{mdspan}%
2515025221
\begin{itemdecl}
2515125222
constexpr size_type size() const noexcept;

0 commit comments

Comments
 (0)