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

Method swap

Examples/NoModules/Chapter 17/Ex17_01A/Array.h:76–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74// Swap member function template
75template <typename T>
76void Array<T>::swap(Array& other) noexcept
77{
78 std::swap(m_elements, other.m_elements); // Swap two pointers
79 std::swap(m_size, other.m_size); // Swap the sizes
80}
81
82// Swap non-member function template (optional)
83template <typename T>

Callers 1

swapFunction · 0.45

Calls 1

swapFunction · 0.70

Tested by

no test coverage detected