diff --git a/source/containers.tex b/source/containers.tex index 4c072e4805..c2aa20e948 100644 --- a/source/containers.tex +++ b/source/containers.tex @@ -10571,18 +10571,18 @@ // \ref{span.cons}, constructors, copy, and assignment constexpr span() noexcept; - constexpr span(pointer ptr, size_type count); - constexpr span(pointer first, pointer last); + template + constexpr span(It first, size_type count); + tmeplate + constexpr span(It first, End last); template constexpr span(element_type (&arr)[N]) noexcept; template constexpr span(array& arr) noexcept; template constexpr span(const array& arr) noexcept; - template - constexpr span(Container& cont); - template - constexpr span(const Container& cont); + template + constexpr span(R&& r); constexpr span(const span& other) noexcept = default; template constexpr span(const span& s) noexcept; @@ -10633,16 +10633,16 @@ size_type size_; // \expos }; + template + span(It, End) -> span>>; template span(T (&)[N]) -> span; template span(array&) -> span; template span(const array&) -> span; - template - span(Container&) -> span; - template - span(const Container&) -> span; + template + span(R&&) -> span>>; } \end{codeblock} @@ -10669,52 +10669,84 @@ \indexlibraryctor{span}% \begin{itemdecl} -constexpr span(pointer ptr, size_type count); +template + constexpr span(It first, size_type count); \end{itemdecl} \begin{itemdescr} +\pnum +\constraints +Let \tcode{U} be \tcode{remove_reference_t>}. +\begin{itemize} +\item \tcode{It} satisfies \libconcept{contiguous_iterator}. +\item +\tcode{is_convertible_v} is \tcode{true}. +\begin{note} +The intent is to allow only qualification conversions +of the iterator reference type to \tcode{element_type}. +\end{note} +\end{itemize} + \pnum \expects -\range{ptr}{ptr + count} is a valid range. +\begin{itemize} +\item \range{first}{first + count} is a valid range. +\item \tcode{It} models \libconcept{contiguous_iterator}. +\item If \tcode{extent} is not equal to \tcode{dynamic_extent}, then \tcode{count} is equal to \tcode{extent}. +\end{itemize} \pnum \effects -Constructs a \tcode{span} that is a view over the range \range{ptr}{ptr + count}. - -\pnum -\ensures -\tcode{size() == count \&\& data() == ptr}. +Initializes \tcode{data_} with \tcode{to_address(first)} and +\tcode{size_} with \tcode{count}. \pnum \throws -Nothing. +When and what \tcode{to_address(first)} throws. \end{itemdescr} \indexlibraryctor{span}% \begin{itemdecl} -constexpr span(pointer first, pointer last); +template + constexpr span(It first, End last); \end{itemdecl} \begin{itemdescr} \pnum +\constraints +Let \tcode{U} be \tcode{remove_reference_t>}. +\begin{itemize} +\item +\tcode{is_convertible_v} is \tcode{true}. +\begin{note} +The intent is to allow only qualification conversions +of the iterator reference type to \tcode{element_type}. +\end{note} +\item \tcode{It} satisfies \libconcept{contiguous_iterator}. +\item \tcode{End} satisfies \tcode{\libconcept{sized_sentinel_for}}. +\item \tcode{is_convertible_v} is \tcode{false}. +\end{itemize} + \expects -\range{first}{last} is a valid range. +\begin{itemize} +\item If \tcode{extent} is not equal to \tcode{dynamic_extent}, then \tcode{last - first} is equal to \tcode{extent}. +\item \range{first}{last} is a valid range. +\item \tcode{It} models \libconcept{contiguous_iterator}. +\item \tcode{End} models \tcode{\libconcept{sized_sentinel_for}}. +\end{itemize} \pnum \effects -Constructs a span that is a view over the range \range{first}{last}. - -\pnum -\ensures -\tcode{size() == last - first \&\& data() == first}. +Initializes \tcode{data_} with \tcode{to_address(first)} and +\tcode{size_} with \tcode{last - first}. \pnum \throws -Nothing. +When and what \tcode{to_address(first)} throws. \end{itemdescr} \indexlibraryctor{span}% @@ -10743,37 +10775,47 @@ \indexlibraryctor{span}% \begin{itemdecl} -template constexpr span(Container& cont); -template constexpr span(const Container& cont); +template constexpr span(R&& r); \end{itemdecl} \begin{itemdescr} \pnum \constraints +Let \tcode{U} be \tcode{remove_reference_t>}. \begin{itemize} -\item \tcode{extent == dynamic_extent} is \tcode{true}, -\item \tcode{Container} is not a specialization of \tcode{span}, -\item \tcode{Container} is not a specialization of \tcode{array}, -\item \tcode{is_array_v} is \tcode{false}, -\item \tcode{data(cont)} and \tcode{size(cont)} are both well-formed, and -\item \tcode{remove_pointer_t(*)[]} is convertible to \tcode{ElementType(*)[]}. +\item \tcode{extent == dynamic_extent} is \tcode{true}. +\item \tcode{R} satisfies \tcode{ranges::\libconcept{contiguous_range}} and + \tcode{ranges::\libconcept{sized_range}}. +\item Either \tcode{R} satisfies \exposconcept{forwarding-range} or +\tcode{is_const_v} is \tcode{true}. +\item \tcode{remove_cvref_t} is not a specialization of \tcode{span}. +\item \tcode{remove_cvref_t} is not a specialization of \tcode{array}. +\item \tcode{is_array_v>} is \tcode{false}. +\item +\tcode{is_convertible_v} is \tcode{true}. +\begin{note} +The intent is to allow only qualification conversions +of the iterator reference type to \tcode{element_type}. +\end{note} \end{itemize} \pnum \expects -\range{data(cont)}{data(cont) + size(cont)} is a valid range. +\begin{itemize} +\item \tcode{R} models \tcode{ranges::\libconcept{contiguous_range}} and +\tcode{ranges::\libconcept{sized_range}}. +\item If \tcode{is_const_v} is \tcode{false}, +\tcode{R} models \exposconcept{forwarding-range}. +\end{itemize} \pnum \effects -Constructs a \tcode{span} that is a view over the range \range{data(cont)}{data(cont) + size(cont)}. - -\pnum -\ensures -\tcode{size() == size(cont) \&\& data() == data(cont)}. +Initializes \tcode{data_} with \tcode{ranges::data(r)} and +\tcode{size_} with \tcode{ranges::size(r)}. \pnum \throws -What and when \tcode{data(cont)} and \tcode{size(cont)} throw. +What and when \tcode{ranges::data(r)} and \tcode{ranges::size(r)} throw. \end{itemdescr} \indexlibraryctor{span}% @@ -10822,6 +10864,32 @@ \tcode{size() == other.size() \&\& data() == other.data()}. \end{itemdescr} +\rSec3[span.deduct]{Deduction guides} + +\indexlibrary{\idxcode{span}!deduction guide}% +\begin{itemdecl} +template + span(It, End) -> span>>; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\constraints +\tcode{It} satisfies \libconcept{contiguous_iterator}. +\end{itemdescr} + +\indexlibrary{\idxcode{span}!deduction guide}% +\begin{itemdecl} +template + span(R&&) -> span>>; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\constraints +\tcode{R} satisfies \tcode{ranges::\libconcept{contiguous_range}}. +\end{itemdescr} + \rSec3[span.sub]{Subviews} \indexlibrarymember{span}{first}%