isocpp / isocpp/CppCoreGuidelines
Should there be a narrowing cast that uses a precondition check?
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 45.3k
- Forks
- 5.6k
- PR merge metrics
- No merged PRs in 30d
Description
As discussed in #1498, narrow<>() is specified to throw if the narrowing cast loses information, and narrow_cast<>() is specified to tolerate loss of information.
Should the GSL also define a narrowing cast (say, narrow_failfast<>()) that has the precondition that the source value is representable in the destination type?
Contributor guide
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
Start by reading issue #1498 and comparing the stated specifications for narrow<> and narrow_cast<>. Determine whether a precondition-based narrowing cast belongs in the GSL guidance and define the expected behavior and scope. Done means the proposal has a clear decision and any resulting guideline changes are documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100