diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/SplitVector.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/SplitVector.h b/src/SplitVector.h index fcd8b0d0e..e805c50dc 100644 --- a/src/SplitVector.h +++ b/src/SplitVector.h @@ -206,11 +206,12 @@ public: /// Add some new empty elements. /// InsertValue is good for value objects but not for unique_ptr objects /// since they can only be moved from once. - void InsertEmpty(ptrdiff_t position, ptrdiff_t insertLength) { + /// Callers can write to the returned pointer to transform inputs without copies. + T *InsertEmpty(ptrdiff_t position, ptrdiff_t insertLength) { PLATFORM_ASSERT((position >= 0) && (position <= lengthBody)); if (insertLength > 0) { if ((position < 0) || (position > lengthBody)) { - return; + return nullptr; } RoomFor(insertLength); GapTo(position); @@ -222,6 +223,7 @@ public: part1Length += insertLength; gapLength -= insertLength; } + return body.data() + position; } /// Ensure at least length elements allocated, |