cplusplus / cplusplus/draft

[range.chunk.fwd.iter, range.stride.iterator] What precondition is implied here?

Open
#5,730 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

From [range.chunk.fwd.iter-12] / [range.stride.iterator-13]:

constexpr iterator& operator+=(difference_type n) requires random_­access_­range<Base>;

Preconditions: If n is positive, ranges​::​distance(current_­, end_­) > stride_­ * (n - 1) is true.
[Note 1: If n is negative, the Effects paragraph implies a precondition. — end note]

Effects: Equivalent to:

if (x > 0) {
  missing_ = ranges::advance(current_, n_ * x, end_);
} else if (x < 0) {
  ranges::advance(current_, n_ * x + missing_);
  missing_ = 0;
}
return *this;

Maybe it's my English comprehension issue, "If x is negative, the Effects paragraph implies a precondition." What does this mean? What precondition is implied here?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with range.chunk.fwd.iter-12 and range.stride.iterator-13, especially the Preconditions and Effects for operator+=. Determine the precondition implied by the negative-n branch and clarify the standard wording so the requirement is explicit; it is done when the interpretation and any needed editorial change are agreed.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.