Missing reversed params comparison ops for C++17
C++17 needs additional comparison operator overloads with reversed parameters. For C++20 and newer it is unnecessary due to "synthesized three-way comparison" feature.
The comparison operators of expected have not yet be adopt in STL,, refered in P0323R12 .
To avoid the possibly incompatible behaviour with STL, it's not perferred to implement this feature right now.
Free free to tell me if someday it comes :)
I don't understand. The comparison ops for std::expected are available since the beginning, see: https://wg21.link/std23 Chapter: 22.8.6.8 Equality operators
Hi, @mcencora
Equality is not all of the comparison. To acheive equality, we need only two functions, the operator== and operator!=, but six (plus operator<, operator>, operator<= and operator>=) for comparison.
As what you post,
https://wg21.link/std23 Chapter: 22.8.6.8 Equality operators
it only define three overloads of operator==. So this is the thing of equality, and zeus::expected has reached that.
You are missing the point, I am talking here about support for C++17, and to achieve (non-)equality we need in 12 overloads in total.
These are defined in spec (for non-void T): operator==(expected, expected<T2, E2>) operator==(expected, T2) operator==(expected, unexpected<E2>)
So for C++17 you need additionally following: reversed param order: operator==(expected<T2, E2>, expected) operator==(T2, expected) operator==(unexpected<E2>, expected)
not-equal: operator!=(expected, expected<T2, E2>) operator!=(expected, T2) operator!=(expected, unexpected<E2>)
not-equal reversed param order: operator!=(expected<T2, E2>, expected) operator!=(T2, expected) operator!=(unexpected<E2>, expected)
Ahh, I think I get the point now. Let me invastigate the scenario of reversed operands later.
Good catch!!!