Skip to content

fix: enforce unexpected::operator== Mandates and fix its noexcept - #36

Merged
X1aomu merged 1 commit into
zeus-cpp:mainfrom
ComixHe:main
Oct 13, 2026
Merged

X1aomu merged 1 commit into
zeus-cpp:mainfrom
ComixHe:main

Conversation

@ComixHe

@ComixHe ComixHe commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

[expected.un.eq] mandates x.error() == y.error() be well-formed and its result be convertible to bool. Enforce it with a static_assert in the body so malformed comparisons get a clear diagnostic instead of obscure hard errors.

Also fix the noexcept specifier: noexcept(lhs.error() == rhs.error()) only inspected the comparison, ignoring the implicit result-to-bool conversion performed by the return statement, so the operator could be declared noexcept yet terminate at runtime on a throwing conversion.

Use expected_detail::is_nothrow_equality_result_convertible_to_bool_v, which covers the whole expression and matches the convention used by every other equality operator in this header.

[expected.un.eq] mandates x.error() == y.error() be well-formed and
its result be convertible to bool. Enforce it with a static_assert in
the body so malformed comparisons get a clear diagnostic instead of
obscure hard errors.

Also fix the noexcept specifier: noexcept(lhs.error() == rhs.error())
only inspected the comparison, ignoring the implicit result-to-bool
conversion performed by the return statement, so the operator could be
declared noexcept yet terminate at runtime on a throwing conversion.
Use expected_detail::is_nothrow_equality_result_convertible_to_bool_v,
which covers the whole expression and matches the convention used by
every other equality operator in this header.

Signed-off-by: Yuming He <ComixHe1895@outlook.com>
@X1aomu

X1aomu commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Thanks for fixing the noexcept specification and adding the Mandates check for unexpected::operator==, @ComixHe!

I'll merge this and follow up on the related unexpected::operator!= issues separately.

@X1aomu
X1aomu merged commit dbe1f98 into zeus-cpp:main Oct 13, 2026
62 checks passed
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.

2 participants