@@ -10571,18 +10571,18 @@
10571
10571
10572
10572
// \ref {span.cons }, constructors, copy, and assignment
10573
10573
constexpr span() noexcept;
10574
- constexpr span(pointer ptr, size_type count);
10575
- constexpr span(pointer first, pointer last);
10574
+ template<class It>
10575
+ constexpr span(It first, size_type count);
10576
+ tmeplate<class It, class End>
10577
+ constexpr span(It first, End last);
10576
10578
template<size_t N>
10577
10579
constexpr span(element_type (&arr)[N]) noexcept;
10578
10580
template<size_t N>
10579
10581
constexpr span(array<value_type, N>& arr) noexcept;
10580
10582
template<size_t N>
10581
10583
constexpr span(const array<value_type, N>& arr) noexcept;
10582
- template<class Container>
10583
- constexpr span(Container& cont);
10584
- template<class Container>
10585
- constexpr span(const Container& cont);
10584
+ template<class R>
10585
+ constexpr span(R&& r);
10586
10586
constexpr span(const span& other) noexcept = default;
10587
10587
template<class OtherElementType, size_t OtherExtent>
10588
10588
constexpr span(const span<OtherElementType, OtherExtent>& s) noexcept;
@@ -10633,16 +10633,16 @@
10633
10633
size_type size_; // \expos
10634
10634
};
10635
10635
10636
+ template<class It, class End>
10637
+ span(It, End) -> span<remove_reference_t<iter_reference_t<It>>>;
10636
10638
template<class T, size_t N>
10637
10639
span(T (&)[N]) -> span<T, N>;
10638
10640
template<class T, size_t N>
10639
10641
span(array<T, N>&) -> span<T, N>;
10640
10642
template<class T, size_t N>
10641
10643
span(const array<T, N>&) -> span<const T, N>;
10642
- template<class Container>
10643
- span(Container&) -> span<typename Container::value_type>;
10644
- template<class Container>
10645
- span(const Container&) -> span<const typename Container::value_type>;
10644
+ template<class R>
10645
+ span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
10646
10646
}
10647
10647
\end {codeblock }
10648
10648
@@ -10669,52 +10669,88 @@
10669
10669
10670
10670
\indexlibraryctor {span}%
10671
10671
\begin {itemdecl }
10672
- constexpr span(pointer ptr, size_type count);
10672
+ template<class It>
10673
+ constexpr span(It first, size_type count);
10673
10674
\end {itemdecl }
10674
10675
10675
10676
\begin {itemdescr }
10677
+ \pnum
10678
+ \constraints
10679
+ \begin {itemize }
10680
+ \item \tcode {It} satisfies \libconcept {contiguous_iterator}.
10681
+ \item
10682
+ \begin {codeblock }
10683
+ {is_convertible_v<remove_reference_t<iter_reference_t<It>>(*)[], element_type(*)[]>
10684
+ \end {codeblock}
10685
+ is \tcode {true}.
10686
+ \begin {note }
10687
+ The intent is to allow only qualification conversions
10688
+ of the iterator reference type to \tcode {element_type}.
10689
+ \end {note }
10690
+ \end {itemize}
10691
+
10676
10692
\pnum
10677
10693
\expects
10678
- \range {ptr}{ptr + count} is a valid range.
10694
+ \begin {itemize }
10695
+ \item \range {first}{first + count} is a valid range.
10696
+ \item \tcode {It} models \libconcept {contiguous_iterator}.
10697
+ \item
10679
10698
If \tcode {extent} is not equal to \tcode {dynamic_extent},
10680
10699
then \tcode {count} is equal to \tcode {extent}.
10700
+ \end {itemize }
10681
10701
10682
10702
\pnum
10683
10703
\effects
10684
- Constructs a \tcode {span} that is a view over the range \range {ptr}{ptr + count}.
10685
-
10686
- \pnum
10687
- \ensures
10688
- \tcode {size() == count \&\& data() == ptr}.
10704
+ Initializes \tcode {data_} with \tcode {to_address(first)} and
10705
+ \tcode {size_} with \tcode {first + count}.
10689
10706
10690
10707
\pnum
10691
10708
\throws
10692
- Nothing .
10709
+ When and what \tcode {to_address(first)} throws .
10693
10710
\end {itemdescr}
10694
10711
10695
10712
\indexlibraryctor {span}%
10696
10713
\begin {itemdecl }
10697
- constexpr span(pointer first, pointer last);
10714
+ template<class It, class End>
10715
+ constexpr span(It first, End last);
10698
10716
\end {itemdecl }
10699
10717
10700
10718
\begin {itemdescr }
10701
10719
\pnum
10720
+ \constraints
10721
+ \begin {itemize }
10722
+ \item
10723
+ \begin {codeblock }
10724
+ is_convertible_v<remove_reference_t<iter_reference_t<It>>(*)[], element_type(*)[]>
10725
+ \end {codeblock }
10726
+ is \tcode {true}.
10727
+ \begin {note }
10728
+ The intent is to allow only qualification conversions
10729
+ of the iterator reference type to \tcode {element_type}.
10730
+ \end {note }
10731
+ \item \tcode {It} satisfies \libconcept {contiguous_iterator}.
10732
+ \item \tcode {End} satisfies \tcode {\libconcept {sized_sentinel_for}<It>}.
10733
+ \item \tcode {is_convertible_v<End, size_t>} is \tcode {false}.
10734
+ \end {itemize }
10735
+
10702
10736
\expects
10703
- \range {first}{last} is a valid range.
10737
+ \begin {itemize }
10738
+ \item
10704
10739
If \tcode {extent} is not equal to \tcode {dynamic_extent},
10705
10740
then \tcode {last - first} is equal to \tcode {extent}.
10741
+ \item \range {first}{last} is a valid range.
10742
+ \item \tcode {It} models \libconcept {contiguous_iterator}.
10743
+ \item \tcode {End} models \tcode {\libconcept {sized_sentinel_for}<It>}.
10744
+ \end {itemize }
10706
10745
10707
10746
\pnum
10708
10747
\effects
10709
- Constructs a span that is a view over the range \range {first}{last}.
10710
-
10711
- \pnum
10712
- \ensures
10713
- \tcode {size() == last - first \&\& data() == first}.
10748
+ Initializes \tcode {data_} with \tcode {to_address(first)} and
10749
+ \tcode {size_} with \tcode {last - first}.
10714
10750
10715
10751
\pnum
10716
10752
\throws
10717
- Nothing .
10753
+ When and what \tcode {to_address(first)} throws .
10718
10754
\end {itemdescr }
10719
10755
10720
10756
\indexlibraryctor {span}%
@@ -10743,37 +10779,49 @@
10743
10779
10744
10780
\indexlibraryctor {span}%
10745
10781
\begin {itemdecl }
10746
- template<class Container> constexpr span(Container& cont);
10747
- template<class Container> constexpr span(const Container& cont);
10782
+ template<class R> constexpr span(R&& r);
10748
10783
\end {itemdecl }
10749
10784
10750
10785
\begin {itemdescr }
10751
10786
\pnum
10752
10787
\constraints
10753
10788
\begin {itemize }
10754
- \item \tcode {extent == dynamic_extent} is \tcode {true},
10755
- \item \tcode {Container} is not a specialization of \tcode {span},
10756
- \item \tcode {Container} is not a specialization of \tcode {array},
10757
- \item \tcode {is_array_v<Container>} is \tcode {false},
10758
- \item \tcode {data(cont)} and \tcode {size(cont)} are both well-formed, and
10759
- \item \tcode {remove_pointer_t<decltype(data(cont))>(*)[]} is convertible to \tcode {ElementType(*)[]}.
10789
+ \item \tcode {extent == dynamic_extent} is \tcode {true}.
10790
+ \item \tcode {R} satisfies \tcode {ranges::\libconcept {contiguous_range}} and
10791
+ \tcode {ranges::\libconcept {sized_range}}.
10792
+ \item Either \tcode {R} satisfies \exposconcept {forwarding-range} or
10793
+ \tcode {is_const_v<element_type>} is \tcode {true}.
10794
+ \item \tcode {remove_cvref_t<R>} is not a specialization of \tcode {span}.
10795
+ \item \tcode {remove_cvref_t<R>} is not a specialization of \tcode {array}.
10796
+ \item \tcode {is_array_v<remove_cvref_t<R>>} is \tcode {false}.
10797
+ \item \relax
10798
+ \begin {codeblock }
10799
+ is_convertible_v<remove_reference_t<ranges::range_reference_t<R>>(*)[], element_type(*)[]>
10800
+ \end {codeblock }
10801
+ is \tcode {true}.
10802
+ \begin {note }
10803
+ The intent is to allow only qualification conversions
10804
+ of the iterator reference type to \tcode {element_type}.
10805
+ \end {note }
10760
10806
\end {itemize }
10761
10807
10762
10808
\pnum
10763
10809
\expects
10764
- \range {data(cont)}{data(cont) + size(cont)} is a valid range.
10810
+ \begin {itemize }
10811
+ \item \tcode {R} models \tcode {ranges::\libconcept {contiguous_range}} and
10812
+ \tcode {ranges::\libconcept {sized_range}}.
10813
+ \item If \tcode {is_const_v<element_type>} is \tcode {false},
10814
+ \tcode {R} models \exposconcept {forwarding-range}.
10815
+ \end {itemize }
10765
10816
10766
10817
\pnum
10767
10818
\effects
10768
- Constructs a \tcode {span} that is a view over the range \range {data(cont)}{data(cont) + size(cont)}.
10769
-
10770
- \pnum
10771
- \ensures
10772
- \tcode {size() == size(cont) \&\& data() == data(cont)}.
10819
+ Initializes \tcode {data_} with \tcode {ranges::data(r)} and
10820
+ \tcode {size_} with \tcode {ranges::size(r)}.
10773
10821
10774
10822
\pnum
10775
10823
\throws
10776
- What and when \tcode {data(cont )} and \tcode {size(cont )} throw.
10824
+ What and when \tcode {ranges:: data(r )} and \tcode {ranges:: size(r )} throw.
10777
10825
\end {itemdescr }
10778
10826
10779
10827
\indexlibraryctor {span}%
10822
10870
\tcode {size() == other.size() \&\& data() == other.data()}.
10823
10871
\end {itemdescr }
10824
10872
10873
+ \rSec 3[span.deduct]{Deduction guides}
10874
+
10875
+ \indexlibrary {\idxcode {span}!deduction guide}%
10876
+ \begin {itemdecl }
10877
+ template <class It, class End>
10878
+ span(It, End) -> span<remove_reference_t<iter_reference_t<It>>>;
10879
+ \end {itemdecl }
10880
+
10881
+ \begin {itemdescr }
10882
+ \pnum
10883
+ \constraints
10884
+ \tcode {It} satisfies \libconcept {contiguous_iterator}.
10885
+ \end {itemdescr }
10886
+
10887
+ \indexlibrary {\idxcode {span}!deduction guide}%
10888
+ \begin {itemdecl }
10889
+ template<class R>
10890
+ span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
10891
+ \end {itemdecl }
10892
+
10893
+ \begin {itemdescr }
10894
+ \pnum
10895
+ \constraints
10896
+ \tcode {R} satisfies \tcode {ranges::\libconcept {contiguous_range}}.
10897
+ \end {itemdescr }
10898
+
10825
10899
\rSec 3[span.sub]{Subviews}
10826
10900
10827
10901
\indexlibrarymember {span}{first}%
0 commit comments