On 1/4/07, Peter Dimov
The problem with operator& for a smart pointer is that the smart pointer can already have a value. When you hand the address of its raw pointer to QueryInterface, it will overwrite its old value without calling Release() on it. You can guard against that by always zeroing the pointer in operator&, but this leads to a different problem; the expression &x will set x to zero, something that isn't expected or intuitive. Operator& is evil. :-)
One of (or both?) of Microsoft's smart pointers (i.e. IVideoPtr, CComPtr<IVideo>) assert if operator& is called and the pointer is not zero for that reason...or maybe it throws a COM exception, I can't remember. (Not disagreeing with anything that's been said, simply offering information the OP might find useful if he wants to make his operator behave like MS's). --Michael Fawcett