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 struct QEnableIf { typedef T Type; }; template struct QConditional { typedef T Type; }; template struct QConditional { typedef F Type; }; + +template struct QAddConst { typedef const T Type; }; } +// this adds const to non-const objects (like std::as_const) +template +Q_DECL_CONSTEXPR typename QtPrivate::QAddConst::Type &qAsConst(T &t) Q_DECL_NOTHROW { return t; } +// prevent rvalue arguments: +template +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.