@@ -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,84 @@
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
+ Let \tcode {U} be \tcode {remove_reference_t<iter_reference_t<It>>}.
10680
+ \begin {itemize }
10681
+ \item \tcode {It} satisfies \libconcept {contiguous_iterator}.
10682
+ \item
10683
+ \tcode {is_convertible_v<U(*)[], element_type(*)[]>} is \tcode {true}.
10684
+ \begin {note }
10685
+ The intent is to allow only qualification conversions
10686
+ of the iterator reference type to \tcode {element_type}.
10687
+ \end {note }
10688
+ \end {itemize }
10689
+
10676
10690
\pnum
10677
10691
\expects
10678
- \range {ptr}{ptr + count} is a valid range.
10692
+ \begin {itemize }
10693
+ \item \range {first}{first + count} is a valid range.
10694
+ \item \tcode {It} models \libconcept {contiguous_iterator}.
10695
+ \item
10679
10696
If \tcode {extent} is not equal to \tcode {dynamic_extent},
10680
10697
then \tcode {count} is equal to \tcode {extent}.
10698
+ \end {itemize }
10681
10699
10682
10700
\pnum
10683
10701
\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}.
10702
+ Initializes \tcode {data_} with \tcode {to_address(first)} and
10703
+ \tcode {size_} with \tcode {count}.
10689
10704
10690
10705
\pnum
10691
10706
\throws
10692
- Nothing .
10707
+ When and what \tcode {to_address(first)} throws .
10693
10708
\end {itemdescr }
10694
10709
10695
10710
\indexlibraryctor {span}%
10696
10711
\begin {itemdecl }
10697
- constexpr span(pointer first, pointer last);
10712
+ template<class It, class End>
10713
+ constexpr span(It first, End last);
10698
10714
\end {itemdecl }
10699
10715
10700
10716
\begin {itemdescr }
10701
10717
\pnum
10718
+ \constraints
10719
+ Let \tcode {U} be \tcode {remove_reference_t<iter_reference_t<It>>}.
10720
+ \begin {itemize }
10721
+ \item
10722
+ \tcode {is_convertible_v<U(*)[], element_type(*)[]>} is \tcode {true}.
10723
+ \begin {note }
10724
+ The intent is to allow only qualification conversions
10725
+ of the iterator reference type to \tcode {element_type}.
10726
+ \end {note }
10727
+ \item \tcode {It} satisfies \libconcept {contiguous_iterator}.
10728
+ \item \tcode {End} satisfies \tcode {\libconcept {sized_sentinel_for}<It>}.
10729
+ \item \tcode {is_convertible_v<End, size_t>} is \tcode {false}.
10730
+ \end {itemize }
10731
+
10702
10732
\expects
10703
- \range {first}{last} is a valid range.
10733
+ \begin {itemize }
10734
+ \item
10704
10735
If \tcode {extent} is not equal to \tcode {dynamic_extent},
10705
10736
then \tcode {last - first} is equal to \tcode {extent}.
10737
+ \item \range {first}{last} is a valid range.
10738
+ \item \tcode {It} models \libconcept {contiguous_iterator}.
10739
+ \item \tcode {End} models \tcode {\libconcept {sized_sentinel_for}<It>}.
10740
+ \end {itemize }
10706
10741
10707
10742
\pnum
10708
10743
\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}.
10744
+ Initializes \tcode {data_} with \tcode {to_address(first)} and
10745
+ \tcode {size_} with \tcode {last - first}.
10714
10746
10715
10747
\pnum
10716
10748
\throws
10717
- Nothing .
10749
+ When and what \tcode {to_address(first)} throws .
10718
10750
\end {itemdescr }
10719
10751
10720
10752
\indexlibraryctor {span}%
@@ -10743,37 +10775,47 @@
10743
10775
10744
10776
\indexlibraryctor {span}%
10745
10777
\begin {itemdecl }
10746
- template<class Container> constexpr span(Container& cont);
10747
- template<class Container> constexpr span(const Container& cont);
10778
+ template<class R> constexpr span(R&& r);
10748
10779
\end {itemdecl }
10749
10780
10750
10781
\begin {itemdescr }
10751
10782
\pnum
10752
10783
\constraints
10784
+ Let \tcode {U} be \tcode {remove_reference_t<ranges::range_reference_t<R>>}.
10753
10785
\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(*)[]}.
10786
+ \item \tcode {extent == dynamic_extent} is \tcode {true}.
10787
+ \item \tcode {R} satisfies \tcode {ranges::\libconcept {contiguous_range}} and
10788
+ \tcode {ranges::\libconcept {sized_range}}.
10789
+ \item Either \tcode {R} satisfies \exposconcept {forwarding-range} or
10790
+ \tcode {is_const_v<element_type>} is \tcode {true}.
10791
+ \item \tcode {remove_cvref_t<R>} is not a specialization of \tcode {span}.
10792
+ \item \tcode {remove_cvref_t<R>} is not a specialization of \tcode {array}.
10793
+ \item \tcode {is_array_v<remove_cvref_t<R>>} is \tcode {false}.
10794
+ \item
10795
+ \tcode {is_convertible_v<U(*)[], element_type(*)[]>} is \tcode {true}.
10796
+ \begin {note }
10797
+ The intent is to allow only qualification conversions
10798
+ of the iterator reference type to \tcode {element_type}.
10799
+ \end {note }
10760
10800
\end {itemize }
10761
10801
10762
10802
\pnum
10763
10803
\expects
10764
- \range {data(cont)}{data(cont) + size(cont)} is a valid range.
10804
+ \begin {itemize }
10805
+ \item \tcode {R} models \tcode {ranges::\libconcept {contiguous_range}} and
10806
+ \tcode {ranges::\libconcept {sized_range}}.
10807
+ \item If \tcode {is_const_v<element_type>} is \tcode {false},
10808
+ \tcode {R} models \exposconcept {forwarding-range}.
10809
+ \end {itemize }
10765
10810
10766
10811
\pnum
10767
10812
\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)}.
10813
+ Initializes \tcode {data_} with \tcode {ranges::data(r)} and
10814
+ \tcode {size_} with \tcode {ranges::size(r)}.
10773
10815
10774
10816
\pnum
10775
10817
\throws
10776
- What and when \tcode {data(cont )} and \tcode {size(cont )} throw.
10818
+ What and when \tcode {ranges:: data(r )} and \tcode {ranges:: size(r )} throw.
10777
10819
\end {itemdescr }
10778
10820
10779
10821
\indexlibraryctor {span}%
10822
10864
\tcode {size() == other.size() \&\& data() == other.data()}.
10823
10865
\end {itemdescr }
10824
10866
10867
+ \rSec 3[span.deduct]{Deduction guides}
10868
+
10869
+ \indexlibrary {\idxcode {span}!deduction guide}%
10870
+ \begin {itemdecl }
10871
+ template<class It, class End>
10872
+ span(It, End) -> span<remove_reference_t<iter_reference_t<It>>>;
10873
+ \end {itemdecl }
10874
+
10875
+ \begin {itemdescr }
10876
+ \pnum
10877
+ \constraints
10878
+ \tcode {It} satisfies \libconcept {contiguous_iterator}.
10879
+ \end {itemdescr }
10880
+
10881
+ \indexlibrary {\idxcode {span}!deduction guide}%
10882
+ \begin {itemdecl }
10883
+ template<class R>
10884
+ span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
10885
+ \end {itemdecl }
10886
+
10887
+ \begin {itemdescr }
10888
+ \pnum
10889
+ \constraints
10890
+ \tcode {R} satisfies \tcode {ranges::\libconcept {contiguous_range}}.
10891
+ \end {itemdescr }
10892
+
10825
10893
\rSec 3[span.sub]{Subviews}
10826
10894
10827
10895
\indexlibrarymember {span}{first}%
0 commit comments