12 Comments


  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.

    Reply
    1. Arne Mertz

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

      Reply


  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==.

    Reply
    1. Marcel

      Point 3 should read:
      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==.

      Reply
    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.

      Reply
      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.

        Reply
        1. Arne Mertz

          Thanks Marcel, I’ll clarify that part.

          Reply
  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.

    Reply
    1. Arne Mertz

      Hi alfC, thanks for the comment! As you can see, I did mention Boost.Operators in the last sentence. I will cover it in detail in a future post. I knew of Boost.Serialization and its `operator&`, but since it is not exactly the “do as the ints do” way to overload it, I did not mention it here.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *