Skip to content

Implement LWG-4218 Constraint recursion in basic_const_iterator's relational operators due to ADL + CWG-2369 - #6324

Merged
Stephan T. Lavavej (StephanTLavavej) merged 4 commits into
microsoft:mainfrom
frederick-vs-ja:lwg-4218
Jul 11, 2026

Conversation

@frederick-vs-ja

@frederick-vs-ja A. Jiang (frederick-vs-ja) commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Fixes #6316.

Remarks: Currently, MSVC doesn't give constraint recursion for the original example posted in LWG-4218, perhaps because MSVC hasn't completely implemented CWG-2369. In addition to the original example, this PR adds another example causing constraint recursion for both MSVC and Clang when LWG-4218 is not implemented.

Reported DevCom-11111696 for a bug encountered in CI (with workaround added).

Copilot AI review requested due to automatic review settings June 23, 2026 11:09
@frederick-vs-ja
A. Jiang (frederick-vs-ja) requested a review from a team as a code owner June 23, 2026 11:09
@github-project-automation github-project-automation Bot moved this to Initial Review in STL Code Reviews Jun 23, 2026

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

This PR implements the LWG-4218 resolution to fix constraint recursion in basic_const_iterator's reversed relational operators (<, >, <=, >=) that occurs due to ADL combined with CWG-2369. The fix lives in the core <xutility> header that defines basic_const_iterator, and is accompanied by regression tests.

Changes:

  • Add a deduced, same_as<_Iter>-constrained template parameter _Jter to the four reversed relational friend operators and change their basic_const_iterator parameter to basic_const_iterator<_Jter>, breaking the constraint-satisfaction recursion.
  • Add compile-time static_assert tests covering both a heterogeneous-comparison ADL scenario and a reverse_iterator<basic_const_iterator<...>> scenario.

Reviewed changes

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

File Description
stl/inc/xutility Makes the four reversed relational friend operators' right-hand operand depend on a deduced same_as<_Iter> parameter to avoid the LWG-4218 ADL constraint recursion.
tests/std/tests/P2278R4_basic_const_iterator/test.cpp Adds an lwg_4218 namespace with static_asserts that would fail to compile (constraint recursion) without the fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) added the LWG Library Working Group issue label Jun 24, 2026
Copilot AI review requested due to automatic review settings June 30, 2026 01:14

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Comment thread tests/std/tests/P2278R4_basic_const_iterator/test.cpp Outdated
Comment thread stl/inc/xutility
Copilot AI review requested due to automatic review settings July 10, 2026 18:43

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.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Low
@StephanTLavavej

Copy link
Copy Markdown
Member

I'm mirroring this to the MSVC-internal repo. Please notify me if any further changes are pushed, otherwise no action is required.

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) moved this from Ready To Merge to Merging in STL Code Reviews Jul 10, 2026
@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit 22457c2 into microsoft:main Jul 11, 2026
49 checks passed
@github-project-automation github-project-automation Bot moved this from Merging to Done in STL Code Reviews Jul 11, 2026
@StephanTLavavej

Copy link
Copy Markdown
Member

🔁 😻 🔂

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

Labels

LWG Library Working Group issue

3 participants