From 570a7adaa33823b274749100cce5d81b0130f446 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Mon, 2 Feb 2026 11:46:00 +0100 Subject: [PATCH] Move comparison operators of etl::expected to namespace etl (#1287) * Remove AppVeyor build status badge Removed AppVeyor build status badge from README. * Update README.md * Update CONTRIBUTING.md Updated the instructions for contributing. * Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277) * Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`. * Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`. * Move comparison operators of etl::expected to namespace etl --------- Co-authored-by: John Wellbelove Co-authored-by: Sergei --- include/etl/expected.h | 204 ++++++++++++++++++++--------------------- 1 file changed, 102 insertions(+), 102 deletions(-) diff --git a/include/etl/expected.h b/include/etl/expected.h index 722c411e..758e2404 100644 --- a/include/etl/expected.h +++ b/include/etl/expected.h @@ -1296,132 +1296,132 @@ namespace etl } #endif }; -} -//******************************************* -/// Equivalence operators. -//******************************************* -template -ETL_CONSTEXPR14 -bool operator ==(const etl::expected& lhs, const etl::expected& rhs) -{ - if (lhs.has_value() != rhs.has_value()) + //******************************************* + /// Equivalence operators. + //******************************************* + template + ETL_CONSTEXPR14 + bool operator ==(const etl::expected& lhs, const etl::expected& rhs) { - return false; + if (lhs.has_value() != rhs.has_value()) + { + return false; + } + if (lhs.has_value()) + { + return lhs.value() == rhs.value(); + } + return lhs.error() == rhs.error(); } - if (lhs.has_value()) + + //******************************************* + template + ETL_CONSTEXPR14 + bool operator ==(const etl::expected& lhs, const TValue2& rhs) { - return lhs.value() == rhs.value(); + if (!lhs.has_value()) + { + return false; + } + return lhs.value() == rhs; } - return lhs.error() == rhs.error(); -} -//******************************************* -template -ETL_CONSTEXPR14 -bool operator ==(const etl::expected& lhs, const TValue2& rhs) -{ - if (!lhs.has_value()) + //******************************************* + template + ETL_CONSTEXPR14 + bool operator ==(const etl::expected& lhs, const etl::unexpected& rhs) { - return false; + if (lhs.has_value()) + { + return false; + } + return lhs.error() == rhs.error(); } - return lhs.value() == rhs; -} -//******************************************* -template -ETL_CONSTEXPR14 -bool operator ==(const etl::expected& lhs, const etl::unexpected& rhs) -{ - if (lhs.has_value()) + //******************************************* + template + ETL_CONSTEXPR14 + bool operator ==(const etl::expected& lhs, const etl::expected& rhs) { - return false; + if (lhs.has_value() != rhs.has_value()) + { + return false; + } + if (lhs.has_value()) + { + return true; + } + return lhs.error() == rhs.error(); } - return lhs.error() == rhs.error(); -} -//******************************************* -template -ETL_CONSTEXPR14 -bool operator ==(const etl::expected& lhs, const etl::expected& rhs) -{ - if (lhs.has_value() != rhs.has_value()) + //******************************************* + template + ETL_CONSTEXPR14 + bool operator ==(const etl::expected& lhs, const etl::unexpected& rhs) { - return false; + if (lhs.has_value()) + { + return false; + } + return lhs.error() == rhs.error(); } - if (lhs.has_value()) + + //******************************************* + template + ETL_CONSTEXPR14 + bool operator ==(const etl::unexpected& lhs, const etl::unexpected& rhs) { - return true; + return lhs.error() == rhs.error(); } - return lhs.error() == rhs.error(); -} -//******************************************* -template -ETL_CONSTEXPR14 -bool operator ==(const etl::expected& lhs, const etl::unexpected& rhs) -{ - if (lhs.has_value()) + //******************************************* + template + ETL_CONSTEXPR14 + bool operator !=(const etl::expected& lhs, const etl::expected& rhs) { - return false; + return !(lhs == rhs); } - return lhs.error() == rhs.error(); -} -//******************************************* -template -ETL_CONSTEXPR14 -bool operator ==(const etl::unexpected& lhs, const etl::unexpected& rhs) -{ - return lhs.error() == rhs.error(); -} + //******************************************* + template + ETL_CONSTEXPR14 + bool operator !=(const etl::expected& lhs, const TValue2& rhs) + { + return !(lhs == rhs); + } -//******************************************* -template -ETL_CONSTEXPR14 -bool operator !=(const etl::expected& lhs, const etl::expected& rhs) -{ - return !(lhs == rhs); -} + //******************************************* + template + ETL_CONSTEXPR14 + bool operator !=(const etl::expected& lhs, const etl::unexpected& rhs) + { + return !(lhs == rhs); + } -//******************************************* -template -ETL_CONSTEXPR14 -bool operator !=(const etl::expected& lhs, const TValue2& rhs) -{ - return !(lhs == rhs); -} + //******************************************* + template + ETL_CONSTEXPR14 + bool operator !=(const etl::expected& lhs, const etl::expected& rhs) + { + return !(lhs == rhs); + } -//******************************************* -template -ETL_CONSTEXPR14 -bool operator !=(const etl::expected& lhs, const etl::unexpected& rhs) -{ - return !(lhs == rhs); -} + //******************************************* + template + ETL_CONSTEXPR14 + bool operator !=(const etl::expected& lhs, const etl::unexpected& rhs) + { + return !(lhs == rhs); + } -//******************************************* -template -ETL_CONSTEXPR14 -bool operator !=(const etl::expected& lhs, const etl::expected& rhs) -{ - return !(lhs == rhs); -} - -//******************************************* -template -ETL_CONSTEXPR14 -bool operator !=(const etl::expected& lhs, const etl::unexpected& rhs) -{ - return !(lhs == rhs); -} - -//******************************************* -template -ETL_CONSTEXPR14 -bool operator !=(const etl::unexpected& lhs, const etl::unexpected& rhs) -{ - return !(lhs == rhs); + //******************************************* + template + ETL_CONSTEXPR14 + bool operator !=(const etl::unexpected& lhs, const etl::unexpected& rhs) + { + return !(lhs == rhs); + } } //*******************************************