On 2014-08-12, 12:41 PM, Joshua Cranmer 🐧 wrote:
On 8/12/2014 11:12 AM, Vladimir Vukicevic wrote:
It's unfortunate that we can't create a nsCOMPtr<> that will disallow
assignment to a bare pointer without an explicit .get(), but will
still allow conversion to a bare pointer for arg passing purposes.
(Or can we? I admit my C++-fu is not that strong in this area...)  It
would definitely be nice to get rid of already_AddRefed<> (not least
because the spelling of "Refed" always grates when I see it :).

The use of a method like
   operator T*() && = delete;

causes the conversion to fail if the nsCOMPtr is an rvalue (most
temporaries). It still allows T *foo = localVariable; (there's no easy
way around that).

It could also be solved with making operator T*() explicit, but neither of these options are something that we can use in our code base today.

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

Reply via email to