-
Notifications
You must be signed in to change notification settings - Fork 789
LWG Poll 24: P1739R4 Avoid template bloat for safe_ranges in combination with "sub… #3777
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2038,6 +2038,7 @@ | |
constexpr explicit iota_view(W value); | ||
constexpr iota_view(type_identity_t<W> value, | ||
type_identity_t<Bound> bound); | ||
constexpr iota_view(@\exposid{iterator}@ first, @\exposid{sentinel}@ last) : iota_view(*first, last.@\exposid{bound_}@) {} | ||
|
||
constexpr @\exposid{iterator}@ begin() const; | ||
constexpr auto end() const; | ||
|
@@ -2048,7 +2049,7 @@ | |
|
||
template<class W, class Bound> | ||
requires (!@\exposconcept{is-integer-like}@<W> || !@\exposconcept{is-integer-like}@<Bound> || | ||
(@\exposconcept{is-signed-integer-like}@<W> == @\exposconcept{is-signed-integer-like}@<Bound>)) | ||
(@\exposconcept{is-signed-integer-like}@<W> == @\exposconcept{is-signed-integer-like}@<Bound>)) | ||
iota_view(W, Bound) -> iota_view<W, Bound>; | ||
} | ||
\end{codeblock} | ||
|
@@ -4206,9 +4207,37 @@ | |
\pnum | ||
The name \tcode{views::take} denotes a | ||
range adaptor object\iref{range.adaptor.object}. | ||
Given subexpressions \tcode{E} and \tcode{F}, the expression | ||
\tcode{views::take(E, F)} is expression-equivalent to | ||
\tcode{take_view\{E, F\}}. | ||
Let \tcode{E} and \tcode{F} be expressions, | ||
let \tcode{T} be \tcode{remove_cvref_t<decltype((E))>}, and | ||
let \tcode{D} be \tcode{range_difference_t<decltype((E))>}. | ||
If \tcode{decltype((F))} does not model | ||
\tcode{\libconcept{convertible_to}<D>}, | ||
\tcode{views::take(E, F)} is ill-formed. | ||
Otherwise, the expression \tcode{views::take(E, F)} | ||
is expression-equivalent to: | ||
|
||
\begin{itemize} | ||
\item | ||
If \tcode{T} is a specialization | ||
of \tcode{ranges::empty_view}\iref{range.empty.view}, | ||
then \tcode{((void) F, \placeholdernc{decay-copy}(E))}. | ||
|
||
\item | ||
Otherwise, if \tcode{T} models | ||
\libconcept{random_access_range} and \libconcept{sized_range} | ||
and is | ||
\begin{itemize} | ||
\item a specialization of \tcode{span}\iref{views.span} where \tcode{T::extent == dynamic_extent}, | ||
\item a specialization of \tcode{basic_string_view}\iref{string.view}, | ||
\item a specialization of \tcode{ranges::iota_view}\iref{range.iota.view}, or | ||
\item a specialization of \tcode{ranges::subrange}\iref{range.subrange}, | ||
\end{itemize} | ||
then \tcode{T\{ranges::begin(E), ranges::begin(E) + min<D>(ranges::size(E), F)\}}, | ||
except that \tcode{E} is evaluated only once. | ||
|
||
\item | ||
Otherwise, \tcode{ranges::take_view\{E, F\}}. | ||
\end{itemize} | ||
|
||
\pnum | ||
\begin{example} | ||
|
@@ -4560,9 +4589,37 @@ | |
\pnum | ||
The name \tcode{views::drop} denotes | ||
a range adaptor object\iref{range.adaptor.object}. | ||
Given subexpressions \tcode{E} and \tcode{F}, | ||
the expression \tcode{views::drop(E, F)} | ||
is expression-equivalent to \tcode{drop_view\{E, F\}}. | ||
Let \tcode{E} and \tcode{F} be expressions, | ||
let \tcode{T} be \tcode{remove_cvref_t<decltype((E))>}, and | ||
let \tcode{D} be \tcode{range_difference_t<decltype((E))>}. | ||
If \tcode{decltype((F))} does not model | ||
\tcode{\libconcept{convertible_to}<D>}, | ||
\tcode{views::drop(E, F)} is ill-formed. | ||
Comment on lines
+4595
to
+4597
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "model" + ill-formed don't work together; advised LWG in http://lists.isocpp.org/lib/2020/02/15451.php |
||
Otherwise, the expression \tcode{views::drop(E, F)} | ||
is expression-equivalent to: | ||
|
||
\begin{itemize} | ||
\item | ||
If \tcode{T} is a specialization of | ||
\tcode{ranges::empty_view}\iref{range.empty.view}, | ||
then \tcode{((void) F, \placeholdernc{decay-copy}(E))}. | ||
|
||
\item | ||
Otherwise, if \tcode{T} models | ||
\libconcept{random_access_range} and \libconcept{sized_range} | ||
and is | ||
\begin{itemize} | ||
\item a specialization of \tcode{span}\iref{views.span} where \tcode{T::extent == dynamic_extent}, | ||
\item a specialization of \tcode{basic_string_view}\iref{string.view}, | ||
\item a specialization of \tcode{ranges::iota_view}\iref{range.iota.view}, or | ||
\item a specialization of \tcode{ranges::subrange}\iref{range.subrange}, | ||
\end{itemize} | ||
then \tcode{T\{ranges::begin(E) + min<D>(ranges::size(E), F), ranges::end(E)\}}, | ||
except that \tcode{E} is evaluated only once. | ||
|
||
\item | ||
Otherwise, \tcode{ranges::drop_view\{E, F\}}. | ||
\end{itemize} | ||
|
||
\pnum | ||
\begin{example} | ||
|
@@ -5773,26 +5830,35 @@ | |
for an iterator \tcode{i} and non-negative integer \tcode{n}. | ||
|
||
\pnum | ||
The name \tcode{views::counted} denotes a | ||
customization point object\iref{customization.point.object}. | ||
The name \tcode{views::counted} denotes | ||
a customization point object\iref{customization.point.object}. | ||
Let \tcode{E} and \tcode{F} be expressions, | ||
and let \tcode{T} be \tcode{decay_t<decltype((E))>}. | ||
Then the expression \tcode{views::counted(E, F)} is expression-equivalent to: | ||
let \tcode{T} be \tcode{decay_t<decltype((E))>}, and | ||
let \tcode{D} be \tcode{iter_difference_t<T>}. | ||
If \tcode{decltype((F))} does not model | ||
\tcode{\libconcept{convertible_to}<D>}, | ||
\tcode{views::counted(E, F)} is ill-formed. | ||
Comment on lines
+5838
to
+5840
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "model" + ill-formed don't work together; advised LWG in http://lists.isocpp.org/lib/2020/02/15451.php |
||
\begin{note} | ||
This case can result in substitution failure | ||
when \tcode{views::counted(E, F)} | ||
appears in the immediate context of a template instantiation. | ||
\end{note} | ||
Otherwise, \tcode{views::counted(E, F)} | ||
is expression-equivalent to: | ||
|
||
\begin{itemize} | ||
\item If \tcode{T} models \libconcept{input_or_output_iterator} and | ||
\tcode{decltype((F))} models \tcode{\libconcept{convertible_to}<iter_differ\-ence_t<T>>}, | ||
\begin{itemize} | ||
\item \tcode{subrange\{E, E + static_cast<iter_difference_t<T>>(F)\}} | ||
if \tcode{T} models \libconceptx{random_access_\-it\-er\-ator}{random_access_iterator}. | ||
\item Otherwise, | ||
\tcode{subrange\{counted_iterator\{E, F\}, default_sentinel\}}. | ||
\end{itemize} | ||
\item | ||
If \tcode{T} models \libconcept{contiguous_iterator}, | ||
then \tcode{span\{to_address(E), static_cast<D>(F)\}}. | ||
|
||
\item Otherwise, \tcode{views::counted(E, F)} is ill-formed. | ||
\begin{note} | ||
This case can result in substitution failure when \tcode{views::counted(E, F)} | ||
appears in the immediate context of a template instantiation. | ||
\end{note} | ||
\item | ||
Otherwise, if \tcode{T} models \libconcept{random_access_iterator}, | ||
then \tcode{subrange\{E, E + static_cast<D>(F)\}}, | ||
except that \tcode{E} is evaluated only once. | ||
|
||
\item | ||
Otherwise, | ||
\tcode{subrange\{counted_iterator\{E, F\}, default_sentinel\}}. | ||
\end{itemize} | ||
|
||
\rSec2[range.common]{Common view} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"model" + ill-formed don't work together; advised LWG in http://lists.isocpp.org/lib/2020/02/15451.php