From d16efdfc0ef5f998d58dbfe6015a6f0a961d0fae Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 24 Feb 2012 17:41:31 +0100 Subject: QModelIndex: add constexpr The functions dealing with the void* internalPointer() can't be constexpr on GCC 4.6 and Clang 3.2-trunk, even though GCC 4.8-trunk accepts it, because of the casts required. Change-Id: Id04105312da3d0c7632f7df06a34bc5a71120b32 Reviewed-by: Stephen Kelly --- src/corelib/itemmodels/qabstractitemmodel.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/corelib/itemmodels/qabstractitemmodel.h') diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index 109ed32c30..1d9617e8eb 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -59,24 +59,24 @@ class Q_CORE_EXPORT QModelIndex { friend class QAbstractItemModel; public: - inline QModelIndex() : r(-1), c(-1), i(0), m(0) {} + Q_DECL_CONSTEXPR inline QModelIndex() : r(-1), c(-1), i(0), m(0) {} // compiler-generated copy/move ctors/assignment operators are fine! - inline int row() const { return r; } - inline int column() const { return c; } - inline quintptr internalId() const { return i; } + Q_DECL_CONSTEXPR inline int row() const { return r; } + Q_DECL_CONSTEXPR inline int column() const { return c; } + Q_DECL_CONSTEXPR inline quintptr internalId() const { return i; } inline void *internalPointer() const { return reinterpret_cast(i); } inline QModelIndex parent() const; inline QModelIndex sibling(int row, int column) const; inline QModelIndex child(int row, int column) const; inline QVariant data(int role = Qt::DisplayRole) const; inline Qt::ItemFlags flags() const; - inline const QAbstractItemModel *model() const { return m; } - inline bool isValid() const { return (r >= 0) && (c >= 0) && (m != 0); } - inline bool operator==(const QModelIndex &other) const + Q_DECL_CONSTEXPR inline const QAbstractItemModel *model() const { return m; } + Q_DECL_CONSTEXPR inline bool isValid() const { return (r >= 0) && (c >= 0) && (m != 0); } + Q_DECL_CONSTEXPR inline bool operator==(const QModelIndex &other) const { return (other.r == r) && (other.i == i) && (other.c == c) && (other.m == m); } - inline bool operator!=(const QModelIndex &other) const + Q_DECL_CONSTEXPR inline bool operator!=(const QModelIndex &other) const { return !(*this == other); } - inline bool operator<(const QModelIndex &other) const + Q_DECL_CONSTEXPR inline bool operator<(const QModelIndex &other) const { return r < other.r || (r == other.r && (c < other.c @@ -86,7 +86,7 @@ public: private: inline QModelIndex(int arow, int acolumn, void *ptr, const QAbstractItemModel *amodel) : r(arow), c(acolumn), i(reinterpret_cast(ptr)), m(amodel) {} - inline QModelIndex(int arow, int acolumn, quintptr id, const QAbstractItemModel *amodel) + Q_DECL_CONSTEXPR inline QModelIndex(int arow, int acolumn, quintptr id, const QAbstractItemModel *amodel) : r(arow), c(acolumn), i(id), m(amodel) {} int r, c; quintptr i; -- cgit v1.2.3