P4037R1: Supporting signed char and unsigned char in random number generation by TPPPP72 · Pull Request #6422 · microsoft/STL · GitHub
Skip to content

P4037R1: Supporting signed char and unsigned char in random number generation - #6422

Open
Shengxin Pei (TPPPP72) wants to merge 3 commits into
microsoft:mainfrom
TPPPP72:P4037R1
Open

P4037R1: Supporting signed char and unsigned char in random number generation#6422
Shengxin Pei (TPPPP72) wants to merge 3 commits into
microsoft:mainfrom
TPPPP72:P4037R1

Conversation

@TPPPP72

Copy link
Copy Markdown
Contributor

Updated internal type constraints to allow signed char and unsigned char in std::uniform_int_distribution and the operator<< and operator>> stream overloads to handle 8-bit integer types properly.

Removed unnecessary historical workarounds.

Close #6240

Copilot AI balanced review requested due to automatic review settings August 29, 2026 13:36
@TPPPP72
Shengxin Pei (TPPPP72) requested a review from a team as a code owner August 29, 2026 13:36
@github-project-automation github-project-automation Bot moved this to Initial Review in STL Code Reviews Aug 29, 2026
@azure-pipelines

This comment was marked as resolved.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extends <random> support to signed char and unsigned char.

Changes:

  • Expands random engine and distribution type constraints.
  • Promotes 8-bit values for stream serialization.
  • Adds coverage and removes character-casting workarounds.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
stl/inc/random Expands constraints and updates distribution streaming.
tests/std/tests/GH_000178_uniform_int/test.cpp Tests 8-bit distributions and streaming.
tests/std/tests/P0220R1_searchers/test.cpp Removes signed-character generation workaround.
tests/std/tests/P0024R2_parallel_algorithms_replace/test.cpp Removes signed-character generation workarounds.
Suppressed comments (1)

stl/inc/random:49

  • This diagnostic attributes the expanded type set to N4950, but that draft predates P4037R1 and does not permit unsigned char. Cite P4037R1 (or the current wording) so the diagnostic does not direct users to a contradictory requirement.
        "invalid template argument for " #_RandType ": N4950 [rand.req.genl]/1.6 requires one of "                  \
        "unsigned char, unsigned short, unsigned int, unsigned long, or unsigned long long");                       \

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread stl/inc/random Outdated
Comment thread stl/inc/random Outdated
Comment thread tests/std/tests/GH_000178_uniform_int/test.cpp
Comment thread tests/std/tests/GH_000178_uniform_int/test.cpp
@AlexGuteniev

Copy link
Copy Markdown
Contributor

We need to drop silly conditional_t from tests and benchmarks where we use generic integer types.
But maybe not in this PR to keep it focused. Maybe a follow-up issue?

@TPPPP72

Copy link
Copy Markdown
Contributor Author

Comment thread stl/inc/random Outdated
Co-authored-by: A. Jiang <de34@live.cn>
Copilot AI review requested due to automatic review settings August 31, 2026 04:11

This comment was marked as resolved.

Copilot AI review requested due to automatic review settings August 31, 2026 04:23

This comment was marked as resolved.

@TPPPP72

This comment was marked as resolved.

@StephanTLavavej

This comment was marked as resolved.

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) added defect report Applied retroactively cxx26 C++26 feature labels Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cxx26 C++26 feature defect report Applied retroactively

Projects

Status: Initial Review

Development

Successfully merging this pull request may close these issues.

P4037R1 Supporting signed char And unsigned char In <random>

5 participants