[unreachable.sentinel] Incorrect usage example of std::unreachable_sentinel
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
An incorrect description of an example was spotted on Stack Overflow (the comment under the question), [unreachable.sentinel] p2 says:
[Example 1 :
char* p; // set p to point to a character buffer containing newlines char* nl = find(p, unreachable_sentinel, '\n');Provided a newline character really exists in the buffer, the use of
unreachable_sentinelabove potentially makes
the call tofindmore efficient since the loop test against the sentinel does not require a conditional branch. — end
example]
The description says that the example is well-defined if a null character is reachable from p, but std::ranges::find requires the input range to be valid, as [iterator.requirements.general] p12 says:
The result of the application of library functions to invalid ranges is undefined.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the [unreachable.sentinel] p2 example alongside [iterator.requirements.general] p12, which the issue cites. Confirm how the example's range validity requirement affects its description, then update the standard draft wording so the example does not claim validity under an insufficient condition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100