Implement LWG-4072 `std::optional` comparisons: constrain harder #6424
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 234 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.327
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #6424"
general
weight: 0.35
amlel-el-mahrouss
Towards #4522 and #5272.
Previously, we've been constraining
optional's comparison operators in ways quite similar to WG21-P2944R3, so I believe we've actually partially implemented that paper long time ago.optionaland other types, constraints were added in C++17 mode before the initial open-sourcing commit (219514876ea86491de191ceaa88632616bbc0f19).optionalvalues, constraints were added since C++20 mode in #1937.Note that there's currently inconsistency in C++17 mode, which doesn't seem to be a good thing. It's probably better to consistently constrain all these operators either in all modes or only since C++26 mode. As other implementations, especially libc++, constrain them in old modes, I guess we should constrain them in C++17 as indicated by WG21-P2944R3 patched by LWG-4072.
There are three major parts of changes.
1. First, this PR modifies the
_Implicitly_convertible_toconcept to handle return types whose prvalues can be converted toboolbut xvalues can't. Such classes are implementable due C++23 WG21-P0847R7 "Deducing this" as patched by CWG-2813. This part also affects comparisons formove_iteratorandreverse_iterator.2. Second, this PR uses the
_Enable_meowhelper alias templates for operators comparing twooptionals instead ofrequire-clauses. This makes the implementation strategy less clear but is necessary for C++17 mode.3. Third, this PR introduces the
_Enable_self_if_not_optionalhelper alias templates to exactly implement LWG-4072. This approach seems somehow unconventional, but I think it's almost the cleanest way to reusing the existing_Enable_meowhelpers.Test cases for the modification to
_Implicitly_convertible_tois currently not enabled for MSVC because MSVC hasn't implemented CWG-2813 yet. See DevCom-10817483.