isocpp / isocpp/CppCoreGuidelines

Is gsl::narrow intended to work with custom arithmetic types?

Open
#1,819 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
CSS
Stars
45.3k
Forks
5.6k
PR merge metrics
No merged PRs in 30d

Description

An issue ( Microsoft/gsl#990 ) was recently filed in the Microsoft GSL repository, requesting additional support for gsl::narrow on custom arithmetic types. Do the CppCoreGuidelines intend for narrow to support custom arithmetic types.

Also should enums be considered for this narrow support as well? Should narrow be allow to cast from a scoped enum to a different type than its underlying type directly?

Link to the users proof of concept: https://github.com/microsoft/GSL/issues/990#issuecomment-891246530

Contributor guide

Open the contributing guide

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 the linked Microsoft GSL issue and its proof of concept, then review the question about gsl::narrow support for custom arithmetic types and scoped enums. Done means reaching and recording a clear decision about the intended support and casting behavior.

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
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.