[util] Add moving append() call to vector

Add a version of `append()` that takes an rvalue reference.
This commit is contained in:
Justin C. Miller
2023-07-10 01:45:31 -07:00
parent 1ec46ee641
commit a7beb0df18

View File

@@ -110,13 +110,23 @@ public:
/// Add an item onto the array by copying it.
/// \arg item The item to add
/// \returns A reference to the added item
T & append(const T& item)
T & append(const T &item)
{
ensure_capacity(m_size + 1);
m_elements[m_size] = item;
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>