Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ different versioning scheme, following the Haskell community's
* gRPC v1.17.1 is now required to use Bond-over-gRPC.
* Fixed an ambigious `HexDigit` overload compilation error when
compiling with some versions of GCC. ([Pull request
#954](https://github.com/microsoft/bond/pull/954))
#954](https://github.com/Microsoft/bond/pull/954))
* Fixed ambiguous call to `maybe::operator==` that breaks GCC 9
build. ([Pull request
#975](https://github.com/microsoft/bond/pull/975))

## 8.1.0: 2019-03-27 ##

Expand Down
65 changes: 42 additions & 23 deletions cpp/inc/bond/core/maybe.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,29 +185,6 @@ class maybe_common
maybe_common& operator=(maybe_common&&) = default;
#endif

/// @brief Compares two maybes for value equality.
///
/// @return true if both maybes hold nothing; returns false if one maybe
/// holds nothing and the other holds a values; otherwise, calls
/// operator== with the two values.
///
/// @since 8.0.0 (was a member function prior)
friend bool operator==(const maybe_common& lhs, const maybe_common& rhs)
{
return lhs._value == rhs._value;
}

/// @brief Compares two maybes for value inequality.
///
/// See operator==(const maybe_common&,const maybe_common&) for details
/// about how maybes holding nothing are handled.
///
/// @since 8.0.0 (was a member function prior)
friend bool operator!=(const maybe_common& lhs, const maybe_common& rhs)
{
return !(lhs == rhs);
}

/// @brief Compares a maybe and a value for equality.
///
/// @return false if the maybe holds nothing; otherwise, calls
Expand Down Expand Up @@ -370,6 +347,27 @@ class maybe<T, typename boost::disable_if<detail::has_allocator<T> >::type>
return *this;
}

/// @brief Compares two maybes for value equality.
///
/// @return true if both maybes hold nothing; returns false if one maybe
/// holds nothing and the other holds a values; otherwise, calls
/// operator== with the two values.
///
friend bool operator==(const maybe& lhs, const maybe& rhs)
{
return lhs._value == rhs._value;
}

/// @brief Compares two maybes for value inequality.
///
/// See operator==(const maybe_common&,const maybe_common&) for details
/// about how maybes holding nothing are handled.
///
friend bool operator!=(const maybe& lhs, const maybe& rhs)
{
return lhs._value != rhs._value;
}

/// @brief Set the maybe to hold a value, if needed.
///
/// If this instance contains nothing, construct a default instance of
Expand Down Expand Up @@ -559,6 +557,27 @@ class maybe<T, typename boost::enable_if<detail::has_allocator<T> >::type>
// have any competition.
bool operator==(const alloc_holder&) = delete;

/// @brief Compares two maybes for value equality.
///
/// @return true if both maybes hold nothing; returns false if one maybe
/// holds nothing and the other holds a values; otherwise, calls
/// operator== with the two values.
///
friend bool operator==(const maybe& lhs, const maybe& rhs)
{
return lhs._value == rhs._value;
}

/// @brief Compares two maybes for value inequality.
///
/// See operator==(const maybe_common&,const maybe_common&) for details
/// about how maybes holding nothing are handled.
///
friend bool operator!=(const maybe& lhs, const maybe& rhs)
{
return lhs._value != rhs._value;
}

/// @brief Set to non-empty, if needed.
///
/// If this object contains nothing, construct an instance of T, passing
Expand Down