Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2722a3be authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "expected.h - fix bugprone-branch-clone warning"

parents e1b7d47c 4fc9b993
Loading
Loading
Loading
Loading
+12 −28
Original line number Original line Diff line number Diff line
@@ -387,14 +387,10 @@ class _NODISCARD_ expected {


template<class T1, class E1, class T2, class E2>
template<class T1, class E1, class T2, class E2>
constexpr bool operator==(const expected<T1, E1>& x, const expected<T2, E2>& y) {
constexpr bool operator==(const expected<T1, E1>& x, const expected<T2, E2>& y) {
  if (x.has_value() != y.has_value()) {
  if (x.has_value() != y.has_value()) return false;
    return false;
  if (!x.has_value()) return x.error() == y.error();
  } else if (!x.has_value()) {
    return x.error() == y.error();
  } else {
  return *x == *y;
  return *x == *y;
}
}
}


template<class T1, class E1, class T2, class E2>
template<class T1, class E1, class T2, class E2>
constexpr bool operator!=(const expected<T1, E1>& x, const expected<T2, E2>& y) {
constexpr bool operator!=(const expected<T1, E1>& x, const expected<T2, E2>& y) {
@@ -581,35 +577,23 @@ class _NODISCARD_ expected<void, E> {


template<class E1, class E2>
template<class E1, class E2>
constexpr bool operator==(const expected<void, E1>& x, const expected<void, E2>& y) {
constexpr bool operator==(const expected<void, E1>& x, const expected<void, E2>& y) {
  if (x.has_value() != y.has_value()) {
  if (x.has_value() != y.has_value()) return false;
    return false;
  if (!x.has_value()) return x.error() == y.error();
  } else if (!x.has_value()) {
    return x.error() == y.error();
  } else {
  return true;
  return true;
}
}
}


template<class T1, class E1, class E2>
template<class T1, class E1, class E2>
constexpr bool operator==(const expected<T1, E1>& x, const expected<void, E2>& y) {
constexpr bool operator==(const expected<T1, E1>& x, const expected<void, E2>& y) {
  if (x.has_value() != y.has_value()) {
  if (x.has_value() != y.has_value()) return false;
  if (!x.has_value()) return x.error() == y.error();
  return false;
  return false;
  } else if (!x.has_value()) {
    return x.error() == y.error();
  } else {
    return false;
  }
}
}


template<class E1, class T2, class E2>
template<class E1, class T2, class E2>
constexpr bool operator==(const expected<void, E1>& x, const expected<T2, E2>& y) {
constexpr bool operator==(const expected<void, E1>& x, const expected<T2, E2>& y) {
  if (x.has_value() != y.has_value()) {
  if (x.has_value() != y.has_value()) return false;
  if (!x.has_value()) return x.error() == y.error();
  return false;
  return false;
  } else if (!x.has_value()) {
    return x.error() == y.error();
  } else {
    return false;
  }
}
}


template<class E>
template<class E>