On Sun, Jul 21, 2013 at 11:59 PM, Justin Lebar <[email protected]>wrote:
> > It seems really dangerous that there is an implicit conversion from a > strong > > ref ptr to a weak pointer. With C++11, you can thankfully require this > > conversion to be explicit which should alleviate your concern. > > 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 (you could write UseFoo(nsRefPtr<T>(new T)) and Bad Things would happen; there are less obvious ways to write this). I would rewrite UseFoo to take an const nsRefPtr<nsIFoo>& instead and then you don't have to worry about these issues. -Rob _______________________________________________ dev-platform mailing list [email protected] https://lists.mozilla.org/listinfo/dev-platform

