Closed Bug 1096095 Opened 11 years ago Closed 11 years ago

nsTArray should support in-place construction

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1571759

People

(Reporter: xidorn, Unassigned)

Details

Some classes do not have reliable copy or move ctors (e.g. nsLineLayout), which makes it hard to store them in nsTArray. I suggest that nsTArray should have methods for in-place construction for those types to avoid using copy ctors. The current workaround could be wraping a Maybe, which supports in-place construction, inside the nsTArray. But I don't think it's an optimal way.
Component: MFBT → XPCOM
Doesn't AppendElement() with no argument do in-place construction?
(In reply to Please do not ask for reviews for a bit [:bz] from comment #1) > Doesn't AppendElement() with no argument do in-place construction? Yes, but I meant in-place construction with parameter, like Maybe::emplace. Well, I no longer think it is useful now, since classes which cannot be copied or moved should never be directly stored in a nsTArray.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → INVALID

In the meantime, nsTArray_Impl::EmplaceBack was added.

Resolution: INVALID → DUPLICATE
You need to log in before you can comment on or make changes to this bug.