From e09f62031156dbe792d98a161eaf7267095e94a5 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 28 Apr 2016 05:04:34 -0400 Subject: [PATCH] Wrote (did not enable) an alternative wxFileNameWrapper::swap --- src/wxFileNameWrapper.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/wxFileNameWrapper.h b/src/wxFileNameWrapper.h index e39815bfc..ddccfefc0 100644 --- a/src/wxFileNameWrapper.h +++ b/src/wxFileNameWrapper.h @@ -28,6 +28,8 @@ public: void swap(wxFileNameWrapper &that) { if (this != &that) { +#if 1 + // Awful hack number 1 makes gcc 5 choke enum : size_t { Size = sizeof(*this) }; // Do it bitwise. // std::aligned_storage::type buffer; @@ -35,6 +37,31 @@ public: memcpy(&buffer, this, Size); memcpy(this, &that, Size); memcpy(&that, &buffer, Size); +#else + // Awful hack number 2 relies on knowing the class layout + struct Contents + { + void swap(Contents &that) { + m_volume.swap(that.m_volume); + m_dirs.swap(that.m_dirs); + m_name.swap(that.m_name); + m_ext.swap(that.m_ext); + std::swap(m_relative, that.m_relative); + std::swap(m_hasExt, that.m_hasExt); + std::swap(m_dontFollowLinks, that.m_dontFollowLinks); + }; + + wxString m_volume; + wxArrayString m_dirs; + wxString m_name, m_ext; + bool m_relative; + bool m_hasExt; + bool m_dontFollowLinks; + }; + + reinterpret_cast(this)->swap + (*reinterpret_cast(&that)); +#endif } }