summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-11-19 21:30:55 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-11-27 17:14:28 +0100
commitc72bf262ea1f8eb80b7b4c9a56f6bd9e6f77cee4 (patch)
treef51e8c284a859e996bb1d685e480a49941788b37 /src/corelib/global
parent612c8e428e2c4738bd9da029103921bef536f2ac (diff)
Introduce QT_NO_AS_CONST and mark QtBase free of it
Change-Id: I680086e767fe6d5c69eb7103b26150293c69b175 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qttypetraits.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/global/qttypetraits.h b/src/corelib/global/qttypetraits.h
index 1832a1a734..e8939e7d5f 100644
--- a/src/corelib/global/qttypetraits.h
+++ b/src/corelib/global/qttypetraits.h
@@ -23,6 +23,8 @@ constexpr std::underlying_type_t<Enum> qToUnderlying(Enum e) noexcept
return static_cast<std::underlying_type_t<Enum>>(e);
}
+#ifndef QT_NO_AS_CONST
+
// this adds const to non-const objects (like std::as_const)
template <typename T>
constexpr typename std::add_const<T>::type &qAsConst(T &t) noexcept { return t; }
@@ -30,6 +32,8 @@ constexpr typename std::add_const<T>::type &qAsConst(T &t) noexcept { return t;
template <typename T>
void qAsConst(const T &&) = delete;
+#endif // QT_NO_AS_CONST
+
// like std::exchange
template <typename T, typename U = T>
constexpr T qExchange(T &t, U &&newValue)