diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2012-02-24 17:41:31 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-09-24 18:01:45 +0200 |
commit | d16efdfc0ef5f998d58dbfe6015a6f0a961d0fae (patch) | |
tree | d5580a618838b9ed42e00c935e342e9ea234f8d6 /src/corelib/itemmodels/qabstractitemmodel.h | |
parent | 3291e0a77c10a92a63173d9ece4f83661f849ba9 (diff) |
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 <stephen.kelly@kdab.com>
Diffstat (limited to 'src/corelib/itemmodels/qabstractitemmodel.h')
-rw-r--r-- | src/corelib/itemmodels/qabstractitemmodel.h | 20 |
1 files changed, 10 insertions, 10 deletions
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<void*>(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<quintptr>(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; |