Programmers who overload unary operator& should be sentenced to writing libraries that need to operate properly when fed such classes.
|--Peter Dimov, esteemed Boost member, Boost newsgroup June 2002|
Although that's very funny, it's also a pretty strong statement. Why is there such antipathy to the use of this operator?
In this chapter we look at some of the problems that overloading
operator &() can cause. Our solution will be an unexciting one, simply the recommendation that you follow Peter's implicit advice, forswear any use of this overload for shortsighted gains, and avoid much grief down the line.
One thing I should make clear. Anytime in this chapter that I refer to
operator &() it will be the unary form, ...