Skip to content

Commit 17630da

Browse files
burblebeetkoeppe
authored andcommitted
LWG3875 std::ranges::repeat_view<T, IntegerClass>::iterator may be ill-formed
1 parent 94ed1f4 commit 17630da

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

source/ranges.tex

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,7 @@
214214

215215
// \ref{range.repeat}, repeat view
216216
template<@\libconcept{move_constructible}@ T, @\libconcept{semiregular}@ Bound = unreachable_sentinel_t>
217-
requires (is_object_v<T> && @\libconcept{same_as}@<T, remove_cv_t<T>>
218-
&& (@\exposid{is-integer-like}@<Bound> || @\libconcept{same_as}@<Bound, unreachable_sentinel_t>))
217+
requires @\seebelow@
219218
class repeat_view; // freestanding
220219

221220
namespace views { inline constexpr @\unspecnc@ repeat = @\unspecnc@; } // freestanding
@@ -3400,9 +3399,14 @@
34003399

34013400
\begin{codeblock}
34023401
namespace std::ranges {
3402+
template<class T>
3403+
concept @\defexposconceptnc{integer-like-with-usable-difference-type}@ = // \expos
3404+
@\exposid{is-signed-integer-like}@<T> || (@\exposid{is-integer-like}@<T> && @\libconcept{weakly_incrementable}@<T>);
3405+
34033406
template<@\libconcept{move_constructible}@ T, @\libconcept{semiregular}@ Bound = unreachable_sentinel_t>
34043407
requires (is_object_v<T> && @\libconcept{same_as}@<T, remove_cv_t<T>> &&
3405-
(@\exposid{is-integer-like}@<Bound> || @\libconcept{same_as}@<Bound, unreachable_sentinel_t>))
3408+
(@\exposconcept{integer-like-with-usable-difference-type}@<Bound> ||
3409+
@\libconcept{same_as}@<Bound, unreachable_sentinel_t>))
34063410
class @\libglobal{repeat_view}@ : public view_interface<repeat_view<T, Bound>> {
34073411
private:
34083412
// \ref{range.repeat.iterator}, class \tcode{repeat_view::\exposid{iterator}}
@@ -3539,9 +3543,10 @@
35393543

35403544
\begin{codeblock}
35413545
namespace std::ranges {
3542-
template<@\libconcept{move_constructible}@ T, @\libconcept{semiregular}@ Bound = unreachable_sentinel_t>
3546+
template<@\libconcept{move_constructible}@ T, @\libconcept{semiregular}@ Bound>
35433547
requires (is_object_v<T> && @\libconcept{same_as}@<T, remove_cv_t<T>> &&
3544-
(@\exposid{is-integer-like}@<Bound> || @\libconcept{same_as}@<Bound, unreachable_sentinel_t>))
3548+
(@\exposconcept{integer-like-with-usable-difference-type}@<Bound> ||
3549+
@\libconcept{same_as}@<Bound, unreachable_sentinel_t>))
35453550
class repeat_view<T, Bound>::@\exposid{iterator}@ {
35463551
private:
35473552
using @\exposidnc{index-type}@ = // \expos
@@ -3555,9 +3560,7 @@
35553560
using iterator_concept = random_access_iterator_tag;
35563561
using iterator_category = random_access_iterator_tag;
35573562
using value_type = T;
3558-
using difference_type = conditional_t<@\exposid{is-signed-integer-like}@<@\exposid{index-type}@>,
3559-
@\exposid{index-type}@,
3560-
@\placeholdernc{IOTA-DIFF-T}@(@\exposid{index-type}@)>;
3563+
using difference_type = @\seebelow@;
35613564

35623565
@\exposid{iterator}@() = default;
35633566

@@ -3585,6 +3588,12 @@
35853588
}
35863589
\end{codeblock}
35873590

3591+
\pnum
3592+
If \tcode{\exposid{is-signed-integer-like}<\exposid{index-type}>} is \tcode{true},
3593+
the member \grammarterm{typedef-name} \tcode{difference_type}
3594+
denotes \exposid{index-type}.
3595+
Otherwise, it denotes \tcode{\placeholdernc{IOTA-DIFF-T}(\exposid{index-type})}\iref{range.iota.view}.
3596+
35883597
\indexlibraryctor{repeat_view::\exposid{iterator}}%
35893598
\begin{itemdecl}
35903599
constexpr explicit @\exposid{iterator}@(const T* value, @\exposid{index-type}@ b = @\exposid{index-type}@());

0 commit comments

Comments
 (0)