The Three Ps
Another way to identify candidates for friendship is by using the "Three Ps" (Position, Promotion, and Perception), as suggested by Cline et al. [8]. "Position" refers to the case where the object being operated on cannot be the left-most argument. The stream-insertion operators are the most common example of this case, so Position is really a generalization of the "f is operator<<" and "f is operator>>" cases in the Meyers algorithm. Similarly, "Promotion" is simply another way of saying that type conversions are needed on the left-most argument. Finally, "Perception" is an esthetic judgment as to whether or not the calling syntax is improved by using a free function. Cline and his coauthors appear to be among that rare breed who actually like friend functions, going so far as to state that a friend should be preferred over a member function "whenever it improves the readability of the code" [9]. Although Meyers takes a similar view with respect to free functions in general, he is more conservative in promoting the use of friends; in his algorithm, the use of a friend function is dictated solely by need, not esthetics. And, as if to drive home the point, he states, "Whenever you can avoid friend functions, you should, because, much as in real life, friends are often more trouble than they're worth" [6].CUJ