I've been working intermittently on changes to make
nsCOMPtr<T>::operator& private so that nsCOMPtr users don't
accidentally forget to use getter_AddRefs.  (This seems to happen most
often while converting existing code to nsCOMPtr around calls to things
like QueryInterface and CreateInstance that require a cast that is
typically written as an old-style cast).  See bug 59414 for all the
details.  Most of the changes have been checked in, and I'm hoping to
soon flip the switch and make operator& private.  (I probably should
have sent this message earlier, but better late than never.)

These changes require that legitimate users of |nsCOMPtr<T>::operator&|
use |address_of| instead.  For example, to call a function with signature

NS_IMETHOD DoNothing(nsCOMPtr<nsIFoo> *foo);

one would write:

nsCOMPtr<nsIFoo> myFoo(...);
...
DoNothing(address_of(myFoo));  // used to be DoNothing(&myFoo);

So if you're modifying code that uses nsCOMPtr<T>* parameters (most of
which is editor-related code), you should be aware that you will soon
(hopefully) need to start using |address_of|.

-David

-- 
L. David Baron        <URL: http://www.people.fas.harvard.edu/~dbaron/ >
Mozilla Contributor                      <URL: http://www.mozilla.org/ >
Invited Expert, W3C CSS WG          <URL: http://www.w3.org/Style/CSS/ >

Reply via email to