MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / push_back

Method push_back

Exercises/NoModules/Chapter 17/Soln17_01/Array.h:85–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83// then the original Array<> remains untouched.
84template <typename T>
85void Array<T>::push_back(const T& newElement)
86{
87 Array<T> copy{ m_size + 1 }; // Copy...
88 for (size_t i {}; i < m_size; ++i)
89 copy[i] = m_elements[i];
90
91 copy[m_size] = newElement; // ... modify ...
92
93 swap(copy); // ... and swap! (noexcept)
94}
95
96// Swap member function template
97template <typename T>

Callers 15

addAnimalMethod · 0.45
addAnimalMethod · 0.45
addAnimalMethod · 0.45
addAnimalMethod · 0.45
herdMethod · 0.45
addAnimalMethod · 0.45
herdMethod · 0.45
mainFunction · 0.45
readCustomersFunction · 0.45
readCustomersFunction · 0.45
mainFunction · 0.45
generateRandomNumbersFunction · 0.45

Calls 1

swapFunction · 0.70

Tested by

no test coverage detected