Closed Bug 1184235 Opened 4 years ago Closed 4 years ago

mozilla::Vector should have a emplaceBack method

Categories

(Core :: MFBT, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla42
Tracking Status
firefox42 --- fixed

People

(Reporter: fitzgen, Assigned: fitzgen)

References

Details

Attachments

(1 file)

For in-place construction in the vector. Similar to std::vector's methods.
(Don't need general emplace, so I will let someone else implement it if/when they need it.)
Summary: mozilla::Vector should have emplace and emplaceBack methods → mozilla::Vector should have a emplaceBack method
Comment on attachment 8634338 [details] [diff] [review]
Add mozilla::Vector::emplaceBack

Review of attachment 8634338 [details] [diff] [review]:
-----------------------------------------------------------------

::: mfbt/tests/TestVector.cpp
@@ +101,5 @@
> +TestEmplaceBack()
> +{
> +  struct S
> +  {
> +    S(size_t j, size_t k) : j(j), k(k) { }

It would be nice if we made this test more complete by some combination of:

* deleting copy constructors/operator=
* deleting move operator= (I think we can do this)
* counting normal construction and asserting it only happened so many times
* counting move construction and asserting it only happened so many times

Your choice whether to do it in this bug or in another bug.

@@ +131,5 @@
>  main()
>  {
>    VectorTesting::testReserved();
>    VectorTesting::testConstRange();
> +  TestEmplaceBack();

Style nit: I think it would be nice to define VectorTesting::testEmplaceBack, for consistency with the rest of the tests here.
Attachment #8634338 - Flags: review?(nfroyd) → review+
https://hg.mozilla.org/mozilla-central/rev/bb14867fc943
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
You need to log in before you can comment on or make changes to this bug.