Whitespace cleanup in corelib/tools

Change-Id: Ibe796c398a8e5488b7203abb07aa54740744f1ab
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Allan Sandfeld Jensen 2020-10-20 12:19:21 +02:00
parent 9aba868571
commit 05685708b7
25 changed files with 349 additions and 220 deletions

View File

@ -754,7 +754,6 @@ QBitArray operator^(const QBitArray &a1, const QBitArray &a2)
Sets the value referenced by the QBitRef to \a v. Sets the value referenced by the QBitRef to \a v.
*/ */
/***************************************************************************** /*****************************************************************************
QBitArray stream functions QBitArray stream functions
*****************************************************************************/ *****************************************************************************/

View File

@ -44,7 +44,6 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QBitRef; class QBitRef;
class Q_CORE_EXPORT QBitArray class Q_CORE_EXPORT QBitArray
{ {
@ -148,6 +147,7 @@ private:
qsizetype i; qsizetype i;
inline QBitRef(QBitArray &array, qsizetype idx) : a(array), i(idx) { } inline QBitRef(QBitArray &array, qsizetype idx) : a(array), i(idx) { }
friend class QBitArray; friend class QBitArray;
public: public:
inline operator bool() const { return a.testBit(i); } inline operator bool() const { return a.testBit(i); }
inline bool operator!() const { return !a.testBit(i); } inline bool operator!() const { return !a.testBit(i); }

View File

@ -48,7 +48,8 @@ QT_BEGIN_NAMESPACE
template <class Key, class T> template <class Key, class T>
class QCache class QCache
{ {
struct Value { struct Value
{
T *t = nullptr; T *t = nullptr;
qsizetype cost = 0; qsizetype cost = 0;
Value() noexcept = default; Value() noexcept = default;
@ -68,19 +69,20 @@ class QCache
return *this; return *this;
} }
~Value() { delete t; } ~Value() { delete t; }
private: private:
Q_DISABLE_COPY(Value) Q_DISABLE_COPY(Value)
}; };
struct Chain { struct Chain
Chain() noexcept {
: prev(this), next(this) Chain() noexcept : prev(this), next(this) { }
{}
Chain *prev; Chain *prev;
Chain *next; Chain *next;
}; };
struct Node : public Chain { struct Node : public Chain
{
using KeyType = Key; using KeyType = Key;
using ValueType = Value; using ValueType = Value;

View File

@ -320,7 +320,8 @@ static bool isConfigFunction(QEasingCurve::Type type)
type == QEasingCurve::TCBSpline; type == QEasingCurve::TCBSpline;
} }
struct TCBPoint { struct TCBPoint
{
QPointF _point; QPointF _point;
qreal _t; qreal _t;
qreal _c; qreal _c;
@ -1202,9 +1203,9 @@ bool QEasingCurve::operator==(const QEasingCurve &other) const
} else if (d_ptr->config || other.d_ptr->config) { } else if (d_ptr->config || other.d_ptr->config) {
// one one has a config object, which could contain default values // one one has a config object, which could contain default values
res = qFuzzyCompare(amplitude(), other.amplitude()) && res = qFuzzyCompare(amplitude(), other.amplitude())
qFuzzyCompare(period(), other.period()) && && qFuzzyCompare(period(), other.period())
qFuzzyCompare(overshoot(), other.overshoot()); && qFuzzyCompare(overshoot(), other.overshoot());
} }
} }
return res; return res;

View File

@ -49,7 +49,6 @@ QT_REQUIRE_CONFIG(easingcurve);
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QEasingCurvePrivate; class QEasingCurvePrivate;
class QPointF; class QPointF;
class Q_CORE_EXPORT QEasingCurve class Q_CORE_EXPORT QEasingCurve
@ -108,6 +107,7 @@ public:
EasingFunction customType() const; EasingFunction customType() const;
qreal valueForProgress(qreal progress) const; qreal valueForProgress(qreal progress) const;
private: private:
QEasingCurvePrivate *d_ptr; QEasingCurvePrivate *d_ptr;
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM

View File

@ -56,7 +56,6 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
/*! \internal /*! \internal
Element in a QFreeList. ConstReferenceType and ReferenceType are used as Element in a QFreeList. ConstReferenceType and ReferenceType are used as

View File

@ -59,8 +59,7 @@ struct QHashDummyValue
namespace QHashPrivate { namespace QHashPrivate {
// QHash uses a power of two growth policy. // QHash uses a power of two growth policy.
namespace GrowthPolicy namespace GrowthPolicy {
{
inline constexpr size_t maxNumBuckets() noexcept inline constexpr size_t maxNumBuckets() noexcept
{ {
return size_t(1) << (8 * sizeof(size_t) - 1); return size_t(1) << (8 * sizeof(size_t) - 1);
@ -471,7 +470,6 @@ struct Data
return dd; return dd;
} }
void clear() void clear()
{ {
delete[] spans; delete[] spans;
@ -579,7 +577,8 @@ struct Data
return it.node(); return it.node();
} }
struct InsertionResult { struct InsertionResult
{
iterator it; iterator it;
bool initialized; bool initialized;
}; };

View File

@ -172,7 +172,8 @@ template<typename T> inline size_t qHash(const T &t, size_t seed)
namespace QtPrivate { namespace QtPrivate {
struct QHashCombine { struct QHashCombine
{
typedef size_t result_type; typedef size_t result_type;
template <typename T> template <typename T>
constexpr result_type operator()(size_t seed, const T &t) const noexcept(noexcept(qHash(t))) constexpr result_type operator()(size_t seed, const T &t) const noexcept(noexcept(qHash(t)))
@ -180,7 +181,8 @@ struct QHashCombine {
{ return seed ^ (qHash(t) + 0x9e3779b9 + (seed << 6) + (seed >> 2)) ; } { return seed ^ (qHash(t) + 0x9e3779b9 + (seed << 6) + (seed >> 2)) ; }
}; };
struct QHashCombineCommutative { struct QHashCombineCommutative
{
// QHashCombine is a good hash combiner, but is not commutative, // QHashCombine is a good hash combiner, but is not commutative,
// ie. it depends on the order of the input elements. That is // ie. it depends on the order of the input elements. That is
// usually what we want: {0,1,3} should hash differently than // usually what we want: {0,1,3} should hash differently than

View File

@ -205,10 +205,9 @@ public:
return std::pair<Key, T>(i.key(), i.value()); return std::pair<Key, T>(i.key(), i.value());
} }
struct pointer { struct pointer
pointer(value_type&& r_) {
: r(std::move(r_)) pointer(value_type &&r_) : r(std::move(r_)) { }
{}
pointer() = default; pointer() = default;
pointer(const pointer &other) = default; pointer(const pointer &other) = default;
@ -216,9 +215,7 @@ public:
pointer &operator=(const pointer &other) = default; pointer &operator=(const pointer &other) = default;
pointer &operator=(pointer &&other) = default; pointer &operator=(pointer &&other) = default;
value_type& operator*() const { value_type &operator*() const { return r; }
return r;
}
value_type r; value_type r;
const value_type *operator->() const { const value_type *operator->() const {

View File

@ -48,7 +48,6 @@ struct CGPoint;
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QPoint class QPoint
{ {
public: public:
@ -124,79 +123,139 @@ constexpr inline QPoint::QPoint() noexcept : xp(0), yp(0) {}
constexpr inline QPoint::QPoint(int xpos, int ypos) noexcept : xp(xpos), yp(ypos) {} constexpr inline QPoint::QPoint(int xpos, int ypos) noexcept : xp(xpos), yp(ypos) {}
constexpr inline bool QPoint::isNull() const noexcept constexpr inline bool QPoint::isNull() const noexcept
{ return xp == 0 && yp == 0; } {
return xp == 0 && yp == 0;
}
constexpr inline int QPoint::x() const noexcept constexpr inline int QPoint::x() const noexcept
{ return xp; } {
return xp;
}
constexpr inline int QPoint::y() const noexcept constexpr inline int QPoint::y() const noexcept
{ return yp; } {
return yp;
}
constexpr inline void QPoint::setX(int xpos) noexcept constexpr inline void QPoint::setX(int xpos) noexcept
{ xp = xpos; } {
xp = xpos;
}
constexpr inline void QPoint::setY(int ypos) noexcept constexpr inline void QPoint::setY(int ypos) noexcept
{ yp = ypos; } {
yp = ypos;
}
inline int constexpr QPoint::manhattanLength() const inline int constexpr QPoint::manhattanLength() const
{ return qAbs(x())+qAbs(y()); } {
return qAbs(x()) + qAbs(y());
}
constexpr inline int &QPoint::rx() noexcept constexpr inline int &QPoint::rx() noexcept
{ return xp; } {
return xp;
}
constexpr inline int &QPoint::ry() noexcept constexpr inline int &QPoint::ry() noexcept
{ return yp; } {
return yp;
}
constexpr inline QPoint &QPoint::operator+=(const QPoint &p) constexpr inline QPoint &QPoint::operator+=(const QPoint &p)
{ xp+=p.xp; yp+=p.yp; return *this; } {
xp += p.xp;
yp += p.yp;
return *this;
}
constexpr inline QPoint &QPoint::operator-=(const QPoint &p) constexpr inline QPoint &QPoint::operator-=(const QPoint &p)
{ xp-=p.xp; yp-=p.yp; return *this; } {
xp -= p.xp;
yp -= p.yp;
return *this;
}
constexpr inline QPoint &QPoint::operator*=(float factor) constexpr inline QPoint &QPoint::operator*=(float factor)
{ xp = qRound(xp*factor); yp = qRound(yp*factor); return *this; } {
xp = qRound(xp * factor);
yp = qRound(yp * factor);
return *this;
}
constexpr inline QPoint &QPoint::operator*=(double factor) constexpr inline QPoint &QPoint::operator*=(double factor)
{ xp = qRound(xp*factor); yp = qRound(yp*factor); return *this; } {
xp = qRound(xp * factor);
yp = qRound(yp * factor);
return *this;
}
constexpr inline QPoint &QPoint::operator*=(int factor) constexpr inline QPoint &QPoint::operator*=(int factor)
{ xp = xp*factor; yp = yp*factor; return *this; } {
xp = xp * factor;
yp = yp * factor;
return *this;
}
constexpr inline bool operator==(const QPoint &p1, const QPoint &p2) noexcept constexpr inline bool operator==(const QPoint &p1, const QPoint &p2) noexcept
{ return p1.xp == p2.xp && p1.yp == p2.yp; } {
return p1.xp == p2.xp && p1.yp == p2.yp;
}
constexpr inline bool operator!=(const QPoint &p1, const QPoint &p2) noexcept constexpr inline bool operator!=(const QPoint &p1, const QPoint &p2) noexcept
{ return p1.xp != p2.xp || p1.yp != p2.yp; } {
return p1.xp != p2.xp || p1.yp != p2.yp;
}
constexpr inline const QPoint operator+(const QPoint &p1, const QPoint &p2) constexpr inline const QPoint operator+(const QPoint &p1, const QPoint &p2)
{ return QPoint(p1.xp+p2.xp, p1.yp+p2.yp); } {
return QPoint(p1.xp + p2.xp, p1.yp + p2.yp);
}
constexpr inline const QPoint operator-(const QPoint &p1, const QPoint &p2) constexpr inline const QPoint operator-(const QPoint &p1, const QPoint &p2)
{ return QPoint(p1.xp-p2.xp, p1.yp-p2.yp); } {
return QPoint(p1.xp - p2.xp, p1.yp - p2.yp);
}
constexpr inline const QPoint operator*(const QPoint &p, float factor) constexpr inline const QPoint operator*(const QPoint &p, float factor)
{ return QPoint(qRound(p.xp*factor), qRound(p.yp*factor)); } {
return QPoint(qRound(p.xp * factor), qRound(p.yp * factor));
}
constexpr inline const QPoint operator*(const QPoint &p, double factor) constexpr inline const QPoint operator*(const QPoint &p, double factor)
{ return QPoint(qRound(p.xp*factor), qRound(p.yp*factor)); } {
return QPoint(qRound(p.xp * factor), qRound(p.yp * factor));
}
constexpr inline const QPoint operator*(const QPoint &p, int factor) constexpr inline const QPoint operator*(const QPoint &p, int factor)
{ return QPoint(p.xp*factor, p.yp*factor); } {
return QPoint(p.xp * factor, p.yp * factor);
}
constexpr inline const QPoint operator*(float factor, const QPoint &p) constexpr inline const QPoint operator*(float factor, const QPoint &p)
{ return QPoint(qRound(p.xp*factor), qRound(p.yp*factor)); } {
return QPoint(qRound(p.xp * factor), qRound(p.yp * factor));
}
constexpr inline const QPoint operator*(double factor, const QPoint &p) constexpr inline const QPoint operator*(double factor, const QPoint &p)
{ return QPoint(qRound(p.xp*factor), qRound(p.yp*factor)); } {
return QPoint(qRound(p.xp * factor), qRound(p.yp * factor));
}
constexpr inline const QPoint operator*(int factor, const QPoint &p) constexpr inline const QPoint operator*(int factor, const QPoint &p)
{ return QPoint(p.xp*factor, p.yp*factor); } {
return QPoint(p.xp * factor, p.yp * factor);
}
constexpr inline const QPoint operator+(const QPoint &p) constexpr inline const QPoint operator+(const QPoint &p)
{ return p; } {
return p;
}
constexpr inline const QPoint operator-(const QPoint &p) constexpr inline const QPoint operator-(const QPoint &p)
{ return QPoint(-p.xp, -p.yp); } {
return QPoint(-p.xp, -p.yp);
}
constexpr inline QPoint &QPoint::operator/=(qreal c) constexpr inline QPoint &QPoint::operator/=(qreal c)
{ {
@ -246,7 +305,9 @@ public:
constexpr inline QPointF &operator/=(qreal c); constexpr inline QPointF &operator/=(qreal c);
constexpr static inline qreal dotProduct(const QPointF &p1, const QPointF &p2) constexpr static inline qreal dotProduct(const QPointF &p1, const QPointF &p2)
{ return p1.xp * p2.xp + p1.yp * p2.yp; } {
return p1.xp * p2.xp + p1.yp * p2.yp;
}
friend constexpr inline bool operator==(const QPointF &, const QPointF &); friend constexpr inline bool operator==(const QPointF &, const QPointF &);
friend constexpr inline bool operator!=(const QPointF &, const QPointF &); friend constexpr inline bool operator!=(const QPointF &, const QPointF &);
@ -341,12 +402,16 @@ constexpr inline QPointF &QPointF::operator+=(const QPointF &p)
constexpr inline QPointF &QPointF::operator-=(const QPointF &p) constexpr inline QPointF &QPointF::operator-=(const QPointF &p)
{ {
xp-=p.xp; yp-=p.yp; return *this; xp -= p.xp;
yp -= p.yp;
return *this;
} }
constexpr inline QPointF &QPointF::operator*=(qreal c) constexpr inline QPointF &QPointF::operator*=(qreal c)
{ {
xp*=c; yp*=c; return *this; xp *= c;
yp *= c;
return *this;
} }
QT_WARNING_PUSH QT_WARNING_PUSH

View File

@ -240,7 +240,8 @@ public:
{ QScopedPointer<T, Cleanup>::swap(other); } { QScopedPointer<T, Cleanup>::swap(other); }
private: private:
explicit inline QScopedArrayPointer(void *) { explicit inline QScopedArrayPointer(void *)
{
// Enforce the same type. // Enforce the same type.
// If you get a compile error here, make sure you declare // If you get a compile error here, make sure you declare

View File

@ -166,13 +166,25 @@ constexpr inline int &QSize::rheight() noexcept
{ return ht; } { return ht; }
constexpr inline QSize &QSize::operator+=(const QSize &s) noexcept constexpr inline QSize &QSize::operator+=(const QSize &s) noexcept
{ wd+=s.wd; ht+=s.ht; return *this; } {
wd += s.wd;
ht += s.ht;
return *this;
}
constexpr inline QSize &QSize::operator-=(const QSize &s) noexcept constexpr inline QSize &QSize::operator-=(const QSize &s) noexcept
{ wd-=s.wd; ht-=s.ht; return *this; } {
wd -= s.wd;
ht -= s.ht;
return *this;
}
constexpr inline QSize &QSize::operator*=(qreal c) noexcept constexpr inline QSize &QSize::operator*=(qreal c) noexcept
{ wd = qRound(wd*c); ht = qRound(ht*c); return *this; } {
wd = qRound(wd * c);
ht = qRound(ht * c);
return *this;
}
constexpr inline bool operator==(const QSize &s1, const QSize &s2) noexcept constexpr inline bool operator==(const QSize &s1, const QSize &s2) noexcept
{ return s1.wd == s2.wd && s1.ht == s2.ht; } { return s1.wd == s2.wd && s1.ht == s2.ht; }
@ -184,21 +196,30 @@ constexpr inline size_t qHash(const QSize &s, size_t seed = 0) noexcept
{ return qHashMulti(seed, s.wd, s.ht); } { return qHashMulti(seed, s.wd, s.ht); }
constexpr inline const QSize operator+(const QSize &s1, const QSize &s2) noexcept constexpr inline const QSize operator+(const QSize &s1, const QSize &s2) noexcept
{ return QSize(s1.wd+s2.wd, s1.ht+s2.ht); } {
return QSize(s1.wd + s2.wd, s1.ht + s2.ht);
}
constexpr inline const QSize operator-(const QSize &s1, const QSize &s2) noexcept constexpr inline const QSize operator-(const QSize &s1, const QSize &s2) noexcept
{ return QSize(s1.wd-s2.wd, s1.ht-s2.ht); } {
return QSize(s1.wd - s2.wd, s1.ht - s2.ht);
}
constexpr inline const QSize operator*(const QSize &s, qreal c) noexcept constexpr inline const QSize operator*(const QSize &s, qreal c) noexcept
{ return QSize(qRound(s.wd*c), qRound(s.ht*c)); } {
return QSize(qRound(s.wd * c), qRound(s.ht * c));
}
constexpr inline const QSize operator*(qreal c, const QSize &s) noexcept constexpr inline const QSize operator*(qreal c, const QSize &s) noexcept
{ return QSize(qRound(s.wd*c), qRound(s.ht*c)); } {
return QSize(qRound(s.wd * c), qRound(s.ht * c));
}
inline QSize &QSize::operator/=(qreal c) inline QSize &QSize::operator/=(qreal c)
{ {
Q_ASSERT(!qFuzzyIsNull(c)); Q_ASSERT(!qFuzzyIsNull(c));
wd = qRound(wd/c); ht = qRound(ht/c); wd = qRound(wd / c);
ht = qRound(ht / c);
return *this; return *this;
} }
@ -344,13 +365,25 @@ constexpr inline qreal &QSizeF::rheight() noexcept
{ return ht; } { return ht; }
constexpr inline QSizeF &QSizeF::operator+=(const QSizeF &s) noexcept constexpr inline QSizeF &QSizeF::operator+=(const QSizeF &s) noexcept
{ wd += s.wd; ht += s.ht; return *this; } {
wd += s.wd;
ht += s.ht;
return *this;
}
constexpr inline QSizeF &QSizeF::operator-=(const QSizeF &s) noexcept constexpr inline QSizeF &QSizeF::operator-=(const QSizeF &s) noexcept
{ wd -= s.wd; ht -= s.ht; return *this; } {
wd -= s.wd;
ht -= s.ht;
return *this;
}
constexpr inline QSizeF &QSizeF::operator*=(qreal c) noexcept constexpr inline QSizeF &QSizeF::operator*=(qreal c) noexcept
{ wd *= c; ht *= c; return *this; } {
wd *= c;
ht *= c;
return *this;
}
constexpr inline bool operator==(const QSizeF &s1, const QSizeF &s2) noexcept constexpr inline bool operator==(const QSizeF &s1, const QSizeF &s2) noexcept
{ return qFuzzyCompare(s1.wd, s2.wd) && qFuzzyCompare(s1.ht, s2.ht); } { return qFuzzyCompare(s1.wd, s2.wd) && qFuzzyCompare(s1.ht, s2.ht); }
@ -359,21 +392,30 @@ constexpr inline bool operator!=(const QSizeF &s1, const QSizeF &s2) noexcept
{ return !qFuzzyCompare(s1.wd, s2.wd) || !qFuzzyCompare(s1.ht, s2.ht); } { return !qFuzzyCompare(s1.wd, s2.wd) || !qFuzzyCompare(s1.ht, s2.ht); }
constexpr inline const QSizeF operator+(const QSizeF &s1, const QSizeF &s2) noexcept constexpr inline const QSizeF operator+(const QSizeF &s1, const QSizeF &s2) noexcept
{ return QSizeF(s1.wd+s2.wd, s1.ht+s2.ht); } {
return QSizeF(s1.wd + s2.wd, s1.ht + s2.ht);
}
constexpr inline const QSizeF operator-(const QSizeF &s1, const QSizeF &s2) noexcept constexpr inline const QSizeF operator-(const QSizeF &s1, const QSizeF &s2) noexcept
{ return QSizeF(s1.wd-s2.wd, s1.ht-s2.ht); } {
return QSizeF(s1.wd - s2.wd, s1.ht - s2.ht);
}
constexpr inline const QSizeF operator*(const QSizeF &s, qreal c) noexcept constexpr inline const QSizeF operator*(const QSizeF &s, qreal c) noexcept
{ return QSizeF(s.wd*c, s.ht*c); } {
return QSizeF(s.wd * c, s.ht * c);
}
constexpr inline const QSizeF operator*(qreal c, const QSizeF &s) noexcept constexpr inline const QSizeF operator*(qreal c, const QSizeF &s) noexcept
{ return QSizeF(s.wd*c, s.ht*c); } {
return QSizeF(s.wd * c, s.ht * c);
}
inline QSizeF &QSizeF::operator/=(qreal c) inline QSizeF &QSizeF::operator/=(qreal c)
{ {
Q_ASSERT(!qFuzzyIsNull(c)); Q_ASSERT(!qFuzzyIsNull(c));
wd = wd/c; ht = ht/c; wd = wd / c;
ht = ht / c;
return *this; return *this;
} }

View File

@ -89,7 +89,8 @@ constexpr inline int fromOct(uint c) noexcept
// We typically need an extra bit for qNextPowerOfTwo when determining the next allocation size. // We typically need an extra bit for qNextPowerOfTwo when determining the next allocation size.
constexpr qsizetype MaxAllocSize = (std::numeric_limits<qsizetype>::max)(); constexpr qsizetype MaxAllocSize = (std::numeric_limits<qsizetype>::max)();
struct CalculateGrowingBlockSizeResult { struct CalculateGrowingBlockSizeResult
{
qsizetype size; qsizetype size;
qsizetype elementCount; qsizetype elementCount;
}; };

View File

@ -104,7 +104,8 @@ public:
std::copy(first, last, std::back_inserter(*this)); std::copy(first, last, std::back_inserter(*this));
} }
inline ~QVarLengthArray() { inline ~QVarLengthArray()
{
if (QTypeInfo<T>::isComplex) { if (QTypeInfo<T>::isComplex) {
T *i = ptr + s; T *i = ptr + s;
while (i-- != ptr) while (i-- != ptr)
@ -151,7 +152,8 @@ public:
return *this; return *this;
} }
inline void removeLast() { inline void removeLast()
{
Q_ASSERT(s > 0); Q_ASSERT(s > 0);
if (QTypeInfo<T>::isComplex) if (QTypeInfo<T>::isComplex)
ptr[s - 1].~T(); ptr[s - 1].~T();
@ -160,10 +162,26 @@ public:
inline qsizetype size() const { return s; } inline qsizetype size() const { return s; }
inline qsizetype count() const { return s; } inline qsizetype count() const { return s; }
inline qsizetype length() const { return s; } inline qsizetype length() const { return s; }
inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); } inline T &first()
inline const T& first() const { Q_ASSERT(!isEmpty()); return *begin(); } {
T& last() { Q_ASSERT(!isEmpty()); return *(end() - 1); } Q_ASSERT(!isEmpty());
const T& last() const { Q_ASSERT(!isEmpty()); return *(end() - 1); } return *begin();
}
inline const T &first() const
{
Q_ASSERT(!isEmpty());
return *begin();
}
T &last()
{
Q_ASSERT(!isEmpty());
return *(end() - 1);
}
const T &last() const
{
Q_ASSERT(!isEmpty());
return *(end() - 1);
}
inline bool isEmpty() const { return (s == 0); } inline bool isEmpty() const { return (s == 0); }
inline void resize(qsizetype size); inline void resize(qsizetype size);
inline void clear() { resize(0); } inline void clear() { resize(0); }
@ -179,11 +197,13 @@ public:
template <typename AT> template <typename AT>
inline bool contains(const AT &t) const; inline bool contains(const AT &t) const;
inline T &operator[](qsizetype idx) { inline T &operator[](qsizetype idx)
{
Q_ASSERT(idx >= 0 && idx < s); Q_ASSERT(idx >= 0 && idx < s);
return ptr[idx]; return ptr[idx];
} }
inline const T &operator[](qsizetype idx) const { inline const T &operator[](qsizetype idx) const
{
Q_ASSERT(idx >= 0 && idx < s); Q_ASSERT(idx >= 0 && idx < s);
return ptr[idx]; return ptr[idx];
} }
@ -192,7 +212,8 @@ public:
T value(qsizetype i) const; T value(qsizetype i) const;
T value(qsizetype i, const T &defaultValue) const; T value(qsizetype i, const T &defaultValue) const;
inline void append(const T &t) { inline void append(const T &t)
{
if (s == a) { // i.e. s != 0 if (s == a) { // i.e. s != 0
T copy(t); T copy(t);
reallocate(s, s << 1); reallocate(s, s << 1);
@ -212,7 +233,8 @@ public:
} }
} }
void append(T &&t) { void append(T &&t)
{
if (s == a) if (s == a)
reallocate(s, s << 1); reallocate(s, s << 1);
const qsizetype idx = s++; const qsizetype idx = s++;
@ -241,7 +263,6 @@ public:
void remove(qsizetype i); void remove(qsizetype i);
void remove(qsizetype i, qsizetype n); void remove(qsizetype i, qsizetype n);
inline T *data() { return ptr; } inline T *data() { return ptr; }
inline const T *data() const { return ptr; } inline const T *data() const { return ptr; }
inline const T *constData() const { return ptr; } inline const T *constData() const { return ptr; }
@ -253,7 +274,6 @@ public:
typedef const value_type &const_reference; typedef const value_type &const_reference;
typedef qptrdiff difference_type; typedef qptrdiff difference_type;
typedef T *iterator; typedef T *iterator;
typedef const T *const_iterator; typedef const T *const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<iterator> reverse_iterator;

View File

@ -77,7 +77,8 @@ class QVersionNumber
}; };
static_assert(InlineSegmentCount >= 3); // at least major, minor, micro static_assert(InlineSegmentCount >= 3); // at least major, minor, micro
struct SegmentStorage { struct SegmentStorage
{
// Note: we alias the use of dummy and inline_segments in the use of the // Note: we alias the use of dummy and inline_segments in the use of the
// union below. This is undefined behavior in C++98, but most compilers implement // union below. This is undefined behavior in C++98, but most compilers implement
// the C++11 behavior. The one known exception is older versions of Sun Studio. // the C++11 behavior. The one known exception is older versions of Sun Studio.