On 7/22/2013 3:01 PM, Rob Arnold wrote:

Wouldn't disallowing this implicit conversion break code which does

   void UseFoo(nsIFoo* foo);

   nsCOMPtr<nsIFoo> foo;
   UseFoo(foo);

?  That is an extremely common idiom in our code.

That idiom seems dangerous by itself; the assumption it makes is that the
reference will outlive the callee but that isn't actually enforced anywhere
Doesn't the nsCOMPtr<nsIFoo> foo; enforce it? I'm confused by what you're arguing.


(you could write UseFoo(nsRefPtr<T>(new T)) and Bad Things would happen;
What would be bad about it? The T stays alive during the call to UseFoo.

there are less obvious ways to write this). I would rewrite UseFoo to take
an const nsRefPtr<nsIFoo>& instead
Except that you'd basically be rewriting our entire tree, including all of XPIDL. Let's not try to boil that ocean for marginal benefit.

--BDS

_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to