<ranges>: Fix C2382 when mixing #include <ranges> with import std; - #6436
Open
zika (tycket033-tech) wants to merge 1 commit into
Open
<ranges>: Fix C2382 when mixing #include <ranges> with import std;#6436zika (tycket033-tech) wants to merge 1 commit into
zika (tycket033-tech) wants to merge 1 commit into
Conversation
_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
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 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
noexcepthelper 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6121
_Zip_iterator_sentinel_equalhas a fold expression in itsnoexcept-specifier. When a translation unit both#include <ranges>and does
import std;, the compiler fails to match the two declarationsas equivalent (C2382: redefinition; different exception specifications).
This extracts the fold expression into a variable template
_Zip_iterator_sentinel_equal_is_nothrow; both declarations thenreference a simple name + template arguments, which is trivially matched.