N4175: Default comparisons -- Bjarne Stroustrup
A new WG21 paper is available. If you are not a committee member, please use the comments section below or the std-proposals forum for public discussion.
Document number: N4175
Date: 2014-10-11
Default comparisons
by Bjarne Stroustrup
Excerpt:
Defining comparison operators (
==
,!=
,<
,<=
,>
, and>=
) for simple classes is tedious, repetitive, slightly error-prone, and easily automated. I propose to (implicitly) supply default versions of these operations, if needed. The semantics of=
is equality of every member. The meaning of<
is a lexicographical order of elements. If the simple defaults are unsuitable for a class, a programmer can, as ever, define more suitable ones or suppress the defaults.