File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -96,16 +96,19 @@ class LIBSCRATCHCPP_EXPORT List : public Entity
9696 m_size--;
9797 }
9898
99- /* ! Inserts an item at index. */
100- inline void insert (size_t index, const ValueData &value )
99+ /* ! Inserts an empty item at index and returns the reference to it. Can be used for custom initialization . */
100+ inline ValueData & insertEmpty (size_t index)
101101 {
102102 assert (index >= 0 && index <= size ());
103103 m_size++;
104104 reserve (getAllocSize (m_size));
105105 std::rotate (m_dataPtr->rbegin () + m_dataPtr->size () - m_size, m_dataPtr->rbegin () + m_dataPtr->size () - m_size + 1 , m_dataPtr->rend () - index);
106- value_assign_copy (& m_dataPtr->operator [](index), &value );
106+ return m_dataPtr->operator [](index);
107107 }
108108
109+ /* ! Inserts an item at index. */
110+ inline void insert (size_t index, const ValueData &value) { value_assign_copy (&insertEmpty (index), &value); }
111+
109112 /* ! Inserts an item at index. */
110113 inline void insert (size_t index, const Value &value) { insert (index, value.data ()); }
111114
You can’t perform that action at this time.
0 commit comments