mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 08:45:36 +08:00
refs #624 Implementation of Optional can always use unrestricted unions.
This commit is contained in:
@@ -93,7 +93,6 @@ namespace BlackMisc
|
|||||||
private:
|
private:
|
||||||
bool m_isValid;
|
bool m_isValid;
|
||||||
|
|
||||||
#if defined(Q_COMPILER_UNRESTRICTED_UNIONS)
|
|
||||||
T &dereference() { Q_ASSERT(m_isValid); return m_data.object; }
|
T &dereference() { Q_ASSERT(m_isValid); return m_data.object; }
|
||||||
const T &dereference() const { Q_ASSERT(m_isValid); return m_data.object; }
|
const T &dereference() const { Q_ASSERT(m_isValid); return m_data.object; }
|
||||||
union Data
|
union Data
|
||||||
@@ -104,11 +103,6 @@ namespace BlackMisc
|
|||||||
T object;
|
T object;
|
||||||
};
|
};
|
||||||
Data m_data;
|
Data m_data;
|
||||||
#else
|
|
||||||
T &dereference() { Q_ASSERT(m_isValid); return *reinterpret_cast<T *>(m_data.bytes); }
|
|
||||||
const T &dereference() const { Q_ASSERT(m_isValid); return *reinterpret_cast<const T *>(m_data.bytes); }
|
|
||||||
struct { typename std::aligned_storage<sizeof(T)>::type bytes[1]; } m_data;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
Reference in New Issue
Block a user