Why is there an `equivalent` value for std::strong_ordering?

870 views Asked by At

The valid values of std::strong_ordering are less, equal, equivalent, and greater. However, it appears that strong_ordering::equivalent and strong_ordering::equal are equal (i.e., interchangeable), since in both cases the exposition-only value field equals zero, and there is no other state for the exposition-only constructor to initialize.

It makes sense that strong_ordering doesn't have any separate equivalent value, since equivalent values are always equal when the ordering is strong. But what's the point of making strong_ordering::equivalent a synonym for strong_ordering::equal, as opposed to not defining it at all?

1

There are 1 answers

0
Barry On BEST ANSWER

This allows C::equivalent to be defined for all comparison categories C. There used to be five of them, all of which had this, now just the three.

If you need something like that, it helps to have it. And it costs nothing to provide, so... there it is.