On 2013-07-22 2:59 AM, Justin Lebar 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.

Yeah...

Like I say, maybe there's a way to allow lvalue nsRefPtr<T> to convert
to T*, but disallow the conversion for rvalue nsRefPtr<T>.  That would
be reasonable, I think.

That's not possible in C++11. Thinking about this more, the reason that this works fine for std::shared_ptr is the fact that it does _not_ have a T* implicit conversion operator. Therefore, we can't switch to rvalue references to replace already_AddRefed. :(

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

Reply via email to