Skip to content

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

Open
frederick-vs-ja wants to merge 2 commits into
microsoft:mainfrom
frederick-vs-ja:lwg-4218
Open

Implement LWG-4218 Constraint recursion in basic_const_iterator's relational operators due to ADL + CWG-2369#6324
frederick-vs-ja wants to merge 2 commits into
microsoft:mainfrom
frederick-vs-ja:lwg-4218

Conversation

@frederick-vs-ja

@frederick-vs-ja 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 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 StephanTLavavej added the LWG Library Working Group issue label Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LWG Library Working Group issue

Projects

Status: Initial Review

Development

Successfully merging this pull request may close these issues.

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

3 participants