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

Method swap

Examples/NoModules/Chapter 17/Ex17_03/Array.h:86–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84// Swap member function template
85template <typename T>
86void Array<T>::swap(Array& other) noexcept
87{
88 std::swap(m_elements, other.m_elements); // Swap two pointers
89 std::swap(m_size, other.m_size); // Swap the sizes
90}
91
92// Swap non-member function template (optional)
93template <typename T>

Callers 1

swapFunction · 0.45

Calls 1

swapFunction · 0.70

Tested by

no test coverage detected