| 96 | // Swap member function template |
| 97 | template <typename T> |
| 98 | void Array<T>::swap(Array& other) noexcept |
| 99 | { |
| 100 | std::swap(m_elements, other.m_elements); // Swap two pointers |
| 101 | std::swap(m_size, other.m_size); // Swap the sizes |
| 102 | } |
| 103 | |
| 104 | // Swap non-member function template (optional) |
| 105 | template <typename T> |