AIUI the new constructor would be something like nsRefPtr<T>(nsRefPtr<T>&& aOther)
where "&&" means "r-value", which means "temporary", so "moveable". But I'm not totally sure about being able to return nsRefPtr. Right now, if I do already_AddRefed<T> GetFoo(); Foo* foo = GetFoo(); that's a compile error. In order to leak the reference, I'd have to do foo = GetFoo().forget();, which is relatively easy for reviewers to catch. But if we return nsRefPtr, then if I have nsRefPtr<Foo> GetFoo(); Foo* = GetFoo(); that compiles fine (I think?) because nsRefPtr<T> has an implicit conversion to T*. I'd wager that this is probably pretty hard for reviewers to catch; at least, I don't have confidence I'd catch this mistake. Maybe there's a way to delete the nsRefPtr<T> conversion to T* if the nsRefPtr is an r-value. -Justin On Sun, Jul 21, 2013 at 9:08 PM, Robert O'Callahan <rob...@ocallahan.org> wrote: > On Mon, Jul 22, 2013 at 3:58 PM, L. David Baron <dba...@dbaron.org> wrote: > >> Is the idea here that nsRefPtr/nsCOMPtr/etc. would have move >> constructors, and we'd just return them, and the move constructors >> plus return value optimizations would take care of avoiding excess >> reference counting? >> > > That, plus forget() returns a nsRefPtr. > > Rob > -- > Jtehsauts tshaei dS,o n" Wohfy Mdaon yhoaus eanuttehrotraiitny eovni > le atrhtohu gthot sf oirng iyvoeu rs ihnesa.r"t sS?o Whhei csha iids teoa > stiheer :p atroa lsyazye,d 'mYaonu,r "sGients uapr,e tfaokreg iyvoeunr, > 'm aotr atnod sgaoy ,h o'mGee.t" uTph eann dt hwea lmka'n? gBoutt uIp > waanndt wyeonut thoo mken.o w * > * > _______________________________________________ > dev-platform mailing list > dev-platform@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-platform _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform