Deprecate qAsConst()
std::as_const() is a 100% equivalent replacement. [ChangeLog][Deprecation Notices][QtCore] qAsConst() is now deprecated. You can simply globally search and replace "qAsConst" with "std::as_const" in your code-base. Change-Id: If9b29f9b4119cf5bdb9f0a1ada1271c6bb503916 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>bb10
parent
432d67b43f
commit
c7af8d5808
|
|
@ -5,6 +5,7 @@
|
|||
#define QTTYPETRAITS_H
|
||||
|
||||
#include <QtCore/qtconfigmacros.h>
|
||||
#include <QtCore/qtdeprecationmarkers.h>
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
|
@ -24,14 +25,17 @@ constexpr std::underlying_type_t<Enum> qToUnderlying(Enum e) noexcept
|
|||
}
|
||||
|
||||
#ifndef QT_NO_AS_CONST
|
||||
#if QT_DEPRECATED_SINCE(6, 6)
|
||||
|
||||
// this adds const to non-const objects (like std::as_const)
|
||||
template <typename T>
|
||||
QT_DEPRECATED_VERSION_X_6_6("Use std::as_const() instead.")
|
||||
constexpr typename std::add_const<T>::type &qAsConst(T &t) noexcept { return t; }
|
||||
// prevent rvalue arguments:
|
||||
template <typename T>
|
||||
void qAsConst(const T &&) = delete;
|
||||
|
||||
#endif // QT_DEPRECATED_SINCE(6, 6)
|
||||
#endif // QT_NO_AS_CONST
|
||||
|
||||
#ifndef QT_NO_QEXCHANGE
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
\relates <QtTypeTraits>
|
||||
\since 5.7
|
||||
|
||||
\deprecated [6.6] Use std::as_const() instead.
|
||||
|
||||
Returns \a t cast to \c{const T}.
|
||||
|
||||
This function is a Qt implementation of C++17's std::as_const(),
|
||||
|
|
@ -52,6 +54,8 @@
|
|||
\since 5.7
|
||||
\overload
|
||||
|
||||
\deprecated [6.6]
|
||||
|
||||
This overload is deleted to prevent a dangling reference in code like
|
||||
\snippet code/src_corelib_global_qglobal.cpp as-const-4
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue