Closed Bug 1600079 Opened 6 years ago Closed 6 years ago

Provide factory function for nsAutoPtr

Categories

(Core :: XPCOM, task)

task
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: sg, Unassigned)

Details

It would be good to have a factory function for nsAutoPtr<> similar to MakeRefPtr for RefPtr<> which allows to avoid literal new and use of auto such as in

auto ptr = MakeAutoPtr<DatabasesCompleteCallback>(...);

We're trying to get to the point where we use UniquePtr, rather than nsAutoPtr; I don't think we want to make nsAutoPtr more convenient to use in any way.

Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX

Good to know that. Is there anything preventing replacing uses of nsAutoPtr by UniquePtr?

(In reply to Simon Giesecke [:sg] [he/him] from comment #2)

Good to know that. Is there anything preventing replacing uses of nsAutoPtr by UniquePtr?

People's time. nsAutoPtr's implicit conversion to T*, along with its move-like copy constructor behavior, makes the conversion not-quite-trivial.

Surely it requires some effort. I was asking more to be sure there are no hidden caveats, even if after replacing uses it seems to compile and work fine. Thanks for pointing some things out one may run into. I have just replaced most uses of nsAutoPtr by UniquePtr in dom/indexedDB code (and made use of MakeUnique).

You need to log in before you can comment on or make changes to this bug.