Boost logo

Boost :

From: Ed Brey (brey_at_[hidden])
Date: 1999-11-10 17:15:48


Darin Adler wrote:
>
> 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.

Another option would be to use friend functions within the class.
This method has the property of enclosing all functions related to the
class within the class. Also, it gives the function access to
everything in the class, which conceptually is a good thing, even if a
particular function happens to currently only need public members.

Aside from those differences, I don't know if there are any
differences between friend functions and non-member functions. I
don't know my Koenig lookup very well. Are there any differences in
that respect?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk