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

Method swap

Examples/NoModules/Chapter 21/Ex21_03/Array.h:109–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107// Swap member function template
108template <typename T> requires std::default_initializable<T> && std::destructible<T>
109void Array<T>::swap(Array& other) noexcept
110{
111 std::swap(m_elements, other.m_elements); // Swap two pointers
112 std::swap(m_size, other.m_size); // Swap the sizes
113}
114
115// Swap non-member function template (optional)
116template <typename T> requires std::default_initializable<T> && std::destructible<T>

Callers 1

swapFunction · 0.45

Calls 1

swapFunction · 0.70

Tested by

no test coverage detected