
Your program might work, but anyone else who might include your operator<()> definition in their own code will be extremely surprised when this doesn't> work as expected:> ASSERT_FALSE(shared_ptr<Foo>(new Foo()) == shared_ptr<Foo>(new Foo()));>> When I compare 2 pointers, smart or raw, I want to know if the pointers are equal not the subobjects.
Well, I'd argue with the last sentence, but please note that I wasn't talking about operator == at all. I mentioned operator <, which is documented in shared_ptr as follows: "Returns: an unspecified value such that operator< is a strict weak ordering as described in section 25.3 [lib.alg.sorting] of the C++ standard; under the equivalence relation defined by operator<, !(a < b) && !(b < a), two shared_ptr instances are equivalent if and only if they share ownership or are both empty. Throws: nothing." So as long as operator< implements strict weak ordering, it's fine.