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); + } } //*******************************************