Boost logo

Boost :

From: Darin Adler (darin_at_[hidden])
Date: 1999-11-10 14:15:28

> Offhand, I don't see any compelling argument either way for the member
> vs. non-member versions. The non-member version does allow explicit
> specialization, but I'm pretty well convinced that specialization would
> be a bad idea anyway. Does anyone see a good reason to go one way or
> the other?

I prefer the non-member version.

Although it's not likely, someone could define a class with a user-defined
conversion to a shared_ptr. Non-member functions allow conversions on both
the left and right side arguments. Because of that, I generally prefer
non-member functions for binary operators unless there's a strong reason to
go the other way.

For an example of another form of this same question that came up in the
context of the standard, check out open library issue 179. The question at was raised
because the library doesn't specify that operator == be a non-member for
library-supplied iterator classes.

    -- Darin

Boost list run by bdawes at, gregod at, cpdaniel at, john at