On 8/2/15 7:34 AM, Hubert Figuière wrote:
This is also part of why I'd suggest having an construction method that
will return a smart pointer - preventing the use of raw pointers.

Returning an already_AddRefed would prevent the use of raw pointers, but would leak if the caller used "auto", right?

Returning an nsRefPtr would not prevent the use of raw pointers, allowing a caller to write:

  Foo* foo = Foo:make(); // now we have a dangling pointer

We could avoid the former by not using auto in situations like this. We could avoid the latter by _always_ using auto in situations like this and never using a raw pointer... We're currently much closer to the "never use auto in this situation" world than to the other, of course.

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

Reply via email to