Closed
Bug 919222
Opened 11 years ago
Closed 11 years ago
Add AutoPtr to MFBT
Categories
(Core :: MFBT, defect)
Core
MFBT
Tracking
()
RESOLVED
INVALID
People
(Reporter: bjacob, Unassigned)
References
Details
Attachments
(1 file)
4.39 KB,
patch
|
Details | Diff | Splinter Review |
I am trimming various gfx/ headers like gfxASurface.h and a problem is that they have to include nsAutoPtr.h, which is make expensive to include by being also the header for nsRefPtr, which means that it drags in a lot of XPCOM stuff, like around cycle collection. How about having a AutoPtr class in MFBT instead? We had a AutoPtr class in js/src/ctypes/CTypes.h already. The present class is mostly just a MFBT-ificiation of it. I followed it, rather than the more featureful nsAutoPtr, because we can always add features later if the appear as needed. In particular, note that like the one in ctypes/, this AutoPtr class doesn't cast to T*. You have to call .get() or use !! to evaluate as a bool. There is a comment, copied from the ctypes/ file, explaining why. The nsAutoPtr class solves this in a nontrivial way (see the Ptr nested class inside of it). That looked complicated enough that I'd rather hold off from doing it until someone really needs it.
Attachment #808218 -
Flags: review?(jwalden+bmo)
Comment 1•11 years ago
|
||
The auto_ptr mentality is broken, and it is deprecated in C++11. You really should make it UniquePtr instead and make it act like std::unique_ptr.
Comment 2•11 years ago
|
||
(In reply to Joshua Cranmer [:jcranmer] from comment #1) > The auto_ptr mentality is broken, and it is deprecated in C++11. You really > should make it UniquePtr instead and make it act like std::unique_ptr. Yes please. Having a UniquePtr class would be lovely.
Reporter | ||
Comment 3•11 years ago
|
||
Nevermind, Nathan points out that MFBT already has ScopedDeletePtr which is exactly the same thing.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → INVALID
Updated•11 years ago
|
Attachment #808218 -
Flags: review?(jwalden+bmo)
You need to log in
before you can comment on or make changes to this bug.
Description
•