1. Chris

Excellent article !

There is apparently a typographic issue in the implementation sections for the copy and move assignments, : there are several occurences of the html code &amp where an ampersand character would be expected. I don’t think its a browser issue, as the ampersands display correctly in all the other code snippets.

1. Arne Mertz

Thanks, somehow the plugin seems to have messed up the stored text. Fixed 🙂

2. Marcel

Very nice overview! Just a few remarks:

1. unary

`operator+`

does not obey the rule “do as the ints do”: The result of the built-in operator is a prvalue, you return

`X const&`

. Why?

2. There are 3 properties the equality

`operator==`

should satisfy:
a. Reflexivity: a == a
b. Symmetry: If a == b the b == a (this is not called commutativity)
c. Transitivity: If a == b and b == c then a == c

3. You claim: “operator (what isn’t greater must be less or equal) or in terms of operator is actually a total order. If it is only a partial order you must use operator< and operator==.

1. Marcel

operator (what isn’t greater must be less or equal) or in terms of operator is actually a total order. If it is only a partial order you must use operator< and operator==.

2. Arne Mertz

Hi Marcel, thanks for the analysis. The original German post was written years ago, before I kenw of C++11, and it made no difference whether `operator+` returned a temporary or a reference. I will fix that and the `operator==` properties.

I do not completely understand what you mean in point 3, though. In that sentence I just write that `operator< =` can be written either in terms of `operator>` alone, or in terms of `operator<` and `operator==` together. I did not say anthing about partial or total ordering until after that sentence.

1. Marcel

Sorry for the confusion (your editor didn’t like my input). My point is, that you cannot implement operator (in the sense you claimed: what isn’t greater must be less or equal). That’s only correct, if operator> induces a total ordering.

1. Arne Mertz

Thanks Marcel, I’ll clarify that part.

3. alfC

No mention of Boost.Operators http://www.boost.org/doc/libs/1_57_0/libs/utility/operators.htm ?

Boost.Serialization has an interesting overload for binary operator& as a dual contextual <> (output/input).

I used operator& to return some sort of “logical reference” to the object, possibly this logical reference can be converted to a pointer also for parts of the program that depend on & to return a pointer.