From: Vadim Zeitlin Date: Thu, 11 Sep 2008 13:52:48 +0000 (+0000) Subject: added swap() for the other arrays too (and now committing the right files) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/b2794028ded48b73cf45a3bc6ab9d20bee3a6be0 added swap() for the other arrays too (and now committing the right files) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55551 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/dynarray.h b/include/wx/dynarray.h index 1bbf53ed99..8e579a9c64 100644 --- a/include/wx/dynarray.h +++ b/include/wx/dynarray.h @@ -282,6 +282,21 @@ protected: \ const_iterator begin() const { return m_pItems; } \ const_iterator end() const { return m_pItems + m_nCount; } \ \ + void swap(name& other) \ + { \ + const size_t savedSize = m_nSize; \ + const size_t savedCount = m_nCount; \ + T * const savedItems = m_pItems; \ + \ + m_nSize = other.m_nSize; \ + m_nCount = other.m_nCount; \ + m_pItems = other.m_pItems; \ + \ + other.m_nSize = savedSize; \ + other.m_nCount = savedCount; \ + other.m_pItems = savedItems; \ + } \ + \ /* the following functions may be made directly public because */ \ /* they don't use the type of the elements at all */ \ public: \ @@ -487,6 +502,7 @@ public: \ void reserve(size_type n) { base::reserve(n); } \ void resize(size_type n, value_type v = value_type()) \ { base::resize(n, v); } \ + void swap(name& other) { base::swap(other); } \ } #define _WX_PTROP pointer operator->() const { return m_ptr; }