Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 918
Brian Bi Avatar asked Dec 18 '20 20:12

Brian Bi


Video Answer


1 Answers

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.

like image 55
Barry Avatar answered Sep 19 '22 03:09

Barry