Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Common++/header/PointerVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,18 @@ namespace pcpp
return result;
}

/**
* Removes an element from the vector and transfers ownership to the returned unique pointer.
* @param[in] position An iterator pointing to the element to detach.
* @return An unique pointer that holds ownership of the detached element.
*/
std::unique_ptr<T> getAndDetach(VectorIterator const& position)
{
std::unique_ptr<T> result(*position);
m_Vector.erase(position);
return result;
}

/**
* Return a pointer to the element in a certain index
* @param[in] index The index to retrieve the element from
Expand Down