diff options
-rw-r--r-- | src/corelib/global/qglobal.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 128d8abad7..c84a6b5577 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1046,8 +1046,17 @@ template <typename T> struct QEnableIf<true, T> { typedef T Type; }; template <bool B, typename T, typename F> struct QConditional { typedef T Type; }; template <typename T, typename F> struct QConditional<false, T, F> { typedef F Type; }; + +template <typename T> struct QAddConst { typedef const T Type; }; } +// this adds const to non-const objects (like std::as_const) +template <typename T> +Q_DECL_CONSTEXPR typename QtPrivate::QAddConst<T>::Type &qAsConst(T &t) Q_DECL_NOTHROW { return t; } +// prevent rvalue arguments: +template <typename T> +void qAsConst(const T &&) Q_DECL_EQ_DELETE; + QT_END_NAMESPACE // We need to keep QTypeInfo, QSysInfo, QFlags, qDebug & family in qglobal.h for compatibility with Qt 4. |