1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-29 14:48:39 +02:00

Wrote (did not enable) an alternative wxFileNameWrapper::swap

This commit is contained in:
Paul Licameli 2016-04-28 05:04:34 -04:00
parent 8ef83759a7
commit e09f620311

View File

@ -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<Size>::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<Contents*>(this)->swap
(*reinterpret_cast<Contents*>(&that));
#endif
}
}