mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
[util] Add moving append() call to vector
Add a version of `append()` that takes an rvalue reference.
This commit is contained in:
@@ -117,6 +117,16 @@ public:
|
||||
return m_elements[m_size++];
|
||||
}
|
||||
|
||||
/// Add an item onto the array by copying it.
|
||||
/// \arg item The item to add
|
||||
/// \returns A reference to the added item
|
||||
T & append(T &&item)
|
||||
{
|
||||
ensure_capacity(m_size + 1);
|
||||
m_elements[m_size] = std::move(item);
|
||||
return m_elements[m_size++];
|
||||
}
|
||||
|
||||
/// Construct an item in place onto the end of the array.
|
||||
/// \returns A reference to the added item
|
||||
template <typename... Args>
|
||||
|
||||
Reference in New Issue
Block a user