diff --git a/xpcom/glue/nsTArray.h b/xpcom/glue/nsTArray.h index 98281e68ea71..44c5eeaa7ede 100644 --- a/xpcom/glue/nsTArray.h +++ b/xpcom/glue/nsTArray.h @@ -1604,11 +1604,12 @@ public: // @param aIndex the place to insert the new elements. This must be no // greater than the current length of the array. // @param aCount the number of elements to insert + template elem_type* InsertElementsAt(index_type aIndex, size_type aCount) { - if (!base_type::template InsertSlotsAt(aIndex, aCount, - sizeof(elem_type), - MOZ_ALIGNOF(elem_type))) { + if (!base_type::template InsertSlotsAt(aIndex, aCount, + sizeof(elem_type), + MOZ_ALIGNOF(elem_type))) { return nullptr; } @@ -1622,6 +1623,13 @@ public: return Elements() + aIndex; } + /* MOZ_WARN_UNUSED_RESULT */ + elem_type* InsertElementsAt(index_type aIndex, size_type aCount, + const mozilla::fallible_t&) + { + return InsertElementsAt(aIndex, aCount); + } + // This method inserts elements into the array, constructing them // elem_type's copy constructor (or whatever one-arg constructor // happens to match the Item type). @@ -1629,13 +1637,13 @@ public: // greater than the current length of the array. // @param aCount the number of elements to insert. // @param aItem the value to use when constructing the new elements. - template + template elem_type* InsertElementsAt(index_type aIndex, size_type aCount, const Item& aItem) { - if (!base_type::template InsertSlotsAt(aIndex, aCount, - sizeof(elem_type), - MOZ_ALIGNOF(elem_type))) { + if (!base_type::template InsertSlotsAt(aIndex, aCount, + sizeof(elem_type), + MOZ_ALIGNOF(elem_type))) { return nullptr; } @@ -1649,6 +1657,14 @@ public: return Elements() + aIndex; } + template + /* MOZ_WARN_UNUSED_RESULT */ + elem_type* InsertElementsAt(index_type aIndex, size_type aCount, + const Item& aItem, const mozilla::fallible_t&) + { + return InsertElementsAt(aIndex, aCount, aItem); + } + // This method may be called to minimize the memory used by this array. void Compact() {