mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 20:40:29 +08:00
fixing GCC and Clang warnings and errors
This commit is contained in:
@@ -195,6 +195,7 @@ namespace BlackMisc
|
|||||||
void checkEnd(const ConditionalIterator &other) // debugging
|
void checkEnd(const ConditionalIterator &other) // debugging
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_end == other.m_end && m_end == other.m_iterator);
|
Q_ASSERT(m_end == other.m_end && m_end == other.m_iterator);
|
||||||
|
Q_UNUSED(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -75,20 +75,33 @@ namespace BlackMisc
|
|||||||
explicit operator bool() const { return m_isValid; }
|
explicit operator bool() const { return m_isValid; }
|
||||||
|
|
||||||
//! Dereference operator, returns reference to contained value, undefined if there is no value contained.
|
//! Dereference operator, returns reference to contained value, undefined if there is no value contained.
|
||||||
T &operator *() { Q_ASSERT(m_isValid); return *reinterpret_cast<T *>(m_bytes); }
|
T &operator *() { return dereference(); }
|
||||||
|
|
||||||
//! Dereference operator, returns reference to contained value, undefined if there is no value contained.
|
//! Dereference operator, returns reference to contained value, undefined if there is no value contained.
|
||||||
const T &operator *() const { Q_ASSERT(m_isValid); return *reinterpret_cast<const T *>(m_bytes); }
|
const T &operator *() const { return dereference(); }
|
||||||
|
|
||||||
//! Indirection operator, returns pointer to contained value, undefined if there is no value contained.
|
//! Indirection operator, returns pointer to contained value, undefined if there is no value contained.
|
||||||
T *operator ->() { Q_ASSERT(m_isValid); return reinterpret_cast<T *>(m_bytes); }
|
T *operator ->() { return &dereference(); }
|
||||||
|
|
||||||
//! Indirection operator, returns pointer to contained value, undefined if there is no value contained.
|
//! Indirection operator, returns pointer to contained value, undefined if there is no value contained.
|
||||||
const T *operator ->() const { Q_ASSERT(m_isValid); return reinterpret_cast<const T *>(m_bytes); }
|
const T *operator ->() const { return &dereference(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_isValid;
|
bool m_isValid;
|
||||||
|
|
||||||
|
#if defined(Q_COMPILER_UNRESTRICTED_UNIONS)
|
||||||
|
T &dereference() { Q_ASSERT(m_isValid); return m_obj; }
|
||||||
|
const T &dereference() const { Q_ASSERT(m_isValid); return m_obj; }
|
||||||
|
union
|
||||||
|
{
|
||||||
|
char m_bytes[sizeof(T)];
|
||||||
|
T m_obj;
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
T &dereference() { Q_ASSERT(m_isValid); return *reinterpret_cast<T *>(m_bytes); }
|
||||||
|
const T &dereference() const { Q_ASSERT(m_isValid); return *reinterpret_cast<const T *>(m_bytes); }
|
||||||
char m_bytes[sizeof(T)];
|
char m_bytes[sizeof(T)];
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ namespace BlackMisc
|
|||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! Constructor.
|
//! Constructor.
|
||||||
CRange(I begin, I end) : m_begin(begin), m_end(end) { check(begin, end); }
|
CRange(I begin, I end) : m_begin(begin), m_end(end) { check(&begin, &end); }
|
||||||
|
|
||||||
//! Begin and end iterators.
|
//! Begin and end iterators.
|
||||||
//! @{
|
//! @{
|
||||||
@@ -170,9 +170,9 @@ namespace BlackMisc
|
|||||||
I m_end;
|
I m_end;
|
||||||
|
|
||||||
void check(...) {};
|
void check(...) {};
|
||||||
template <class I2, class F> void check(Iterators::ConditionalIterator<I2, F> begin, Iterators::ConditionalIterator<I2, F> end)
|
template <class I2, class F> void check(Iterators::ConditionalIterator<I2, F> *begin, Iterators::ConditionalIterator<I2, F> *end)
|
||||||
{
|
{
|
||||||
begin.checkEnd(end);
|
begin->checkEnd(*end);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user