<ranges>: Fix C2382 when mixing #include <ranges> with import std; by tycket033-tech · Pull Request #6436 · microsoft/STL · GitHub
Skip to content

<ranges>: Fix C2382 when mixing #include <ranges> with import std; - #6436

Open
zika (tycket033-tech) wants to merge 1 commit into
microsoft:mainfrom
tycket033-tech:issue-6121-zip-sentinel-noexcept
Open

<ranges>: Fix C2382 when mixing #include <ranges> with import std;#6436
zika (tycket033-tech) wants to merge 1 commit into
microsoft:mainfrom
tycket033-tech:issue-6121-zip-sentinel-noexcept

Conversation

@tycket033-tech

Copy link
Copy Markdown
Contributor

Fixes #6121

_Zip_iterator_sentinel_equal has a fold expression in its
noexcept-specifier. When a translation unit both #include <ranges>
and does import std;, the compiler fails to match the two declarations
as equivalent (C2382: redefinition; different exception specifications).

This extracts the fold expression into a variable template
_Zip_iterator_sentinel_equal_is_nothrow; both declarations then
reference a simple name + template arguments, which is trivially matched.

_Zip_iterator_sentinel_equal's noexcept-specifier contains a fold
expression, which the compiler fails to match as equivalent between the
textually-included and module-imported declarations, emitting C2382.
Extract it into a variable template so both declarations reference a
simple name, which is trivially matched.

Fixes microsoft#6121
Copilot AI balanced review requested due to automatic review settings September 4, 2026 18:12
@tycket033-tech
zika (tycket033-tech) requested a review from a team as a code owner September 4, 2026 18:12
@github-project-automation github-project-automation Bot moved this to Initial Review in STL Code Reviews Sep 4, 2026
@azure-pipelines

Copy link
Copy Markdown

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.

🟢 Approval recommended

The focused workaround preserves existing semantics and is covered by the include-all-then-import module test configuration.

Pull request overview

Extracts the zip iterator/sentinel noexcept fold expression into a variable template, avoiding MSVC C2382 when headers and standard-library modules are mixed.

Changes:

  • Adds a named noexcept helper variable template.
  • Reuses it in the function and lambda exception specifications.
File summaries
File Description
stl/inc/ranges Simplifies zip iterator/sentinel exception specifications for module compatibility.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Initial Review

Development

Successfully merging this pull request may close these issues.

<ranges>: _Zip_iterator_sentinel_equal redefinition error (C2382) when mixing #include <ranges> with import std;

2 participants