Skip to content

Let C++20 rewriting synthesize sum's operator!=#299

Merged
Bronek merged 1 commit into
mainfrom
bronek/P5/sum_operator_not_equal
Jul 13, 2026
Merged

Let C++20 rewriting synthesize sum's operator!=#299
Bronek merged 1 commit into
mainfrom
bronek/P5/sum_operator_not_equal

Conversation

@Bronek

@Bronek Bronek commented Jul 13, 2026

Copy link
Copy Markdown
Member

The hand-written operator!= dropped the arity conjuncts operator== carries, so against a sum<> operand its constraint was satisfied while =='s was not: the call reported itself viable and then failed to compile in its own body, where not(lh == rh) found no operator==. A constraint that lies.

Deleting it makes a != b a rewritten !(a == b), which inherits operator=='s constraints by construction, so the two cannot drift apart again.

Closes #281


Stack: P5 of 13 — the release-0.1 bugfix queue, merging bottom-up into main. Based on #298 and to be retargeted to main once it merges; the diff shows only this PR's commits. Every stack boundary was validated with a gcc build and the full test suite on top of main, and the aggregate branch ran the full CI matrix green (#289).

@augmentcode

augmentcode Bot commented Jul 13, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR removes the hand-written operator!= overload for fn::sum<...> and relies on C++20’s rewritten a != b expression.

Changes:

  • Deletes the constrained operator!= implementation from include/fn/sum.hpp
  • Adds compile-time “can compare?” probes in tests/fn/sum.cpp to ensure == and != participate in overload resolution together

Why: Prevents constraint drift where operator!= could appear viable (notably with sum<>) while operator== was not, causing compilation failures inside operator!=’s body.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@Bronek Bronek force-pushed the bronek/P4/sum_value_error_noexcept branch from 683c4a1 to 3beae5a Compare July 13, 2026 12:09
@Bronek Bronek changed the base branch from bronek/P4/sum_value_error_noexcept to main July 13, 2026 14:27
The hand-written `operator!=` dropped the arity conjuncts `operator==` carries, so
against a `sum<>` operand its constraint was satisfied while `==`'s was not: the
call reported itself viable and then failed to compile in its own body, where
`not(lh == rh)` found no `operator==`. A constraint that lies.

Deleting it makes `a != b` a rewritten `!(a == b)`, which inherits `operator==`'s
constraints by construction, so the two cannot drift apart again.

Closes #281

Assisted-by: Claude:claude-opus-4-8[1m]
@Bronek Bronek force-pushed the bronek/P5/sum_operator_not_equal branch from 54e67e6 to dbd8898 Compare July 13, 2026 14:29
@Bronek

Bronek commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

augment review

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread tests/fn/sum.cpp
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sonarqubecloud

Copy link
Copy Markdown

@Bronek

Bronek commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

augment review

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@Bronek Bronek merged commit 1084b9b into main Jul 13, 2026
64 checks passed
Bronek added a commit that referenced this pull request Jul 13, 2026
Retire #281's tripwires: a rewritten != inherits =='s constraints, so the
two now drop out together against the uninstantiable sum<>. The probes move
to the equality section, where #299 puts them and where they belong - the
noexcept section keeps only what it weighs - and carry both operand orders
from #299 plus the empty-on-empty pair the tripwires had.

Assisted-by: Claude:claude-opus-4-8[1m]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sum: operator!= is weaker-constrained than operator== (a requires-expression that lies)

1 participant