diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 1bd01cd30cc..101023db6b8 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -85,6 +85,7 @@ qt_internal_add_module(Core global/qtversionchecks.h global/qtypeinfo.h global/qtypes.cpp global/qtypes.h + global/qtypetraits.h global/qvolatile_p.h global/q20algorithm.h global/q20functional.h diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index e4fe6a45247..bcd0292cdbf 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2797,15 +2797,6 @@ void qAbort() that qExchange() returns a non-const object, so Qt containers may detach. */ -/*! - \fn template std::underlying_type_t qToUnderlying(Enum e) - \relates - \since 6.2 - - Converts the enumerator \a e to the equivalent value expressed in its - enumeration's underlying type. -*/ - /*! \macro Q_LIKELY(expr) \relates diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 09072b8b6db..01a48981329 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -158,13 +158,6 @@ noexcept(std::conjunction_v, std::is_nothr return old; } -// like std::to_underlying -template -constexpr std::underlying_type_t qToUnderlying(Enum e) noexcept -{ - return static_cast>(e); -} - QT_END_NAMESPACE // We need to keep QTypeInfo, QSysInfo, QFlags, qDebug & family in qglobal.h for compatibility with Qt 4. @@ -188,6 +181,7 @@ QT_END_NAMESPACE #include #include #include +#include #include #endif /* __cplusplus */ diff --git a/src/corelib/global/qtypetraits.h b/src/corelib/global/qtypetraits.h new file mode 100644 index 00000000000..7cb02117c68 --- /dev/null +++ b/src/corelib/global/qtypetraits.h @@ -0,0 +1,27 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTYPETRAITS_H +#define QTYPETRAITS_H + +#include + +#include + +#if 0 +#pragma qt_class(QTypeTraits) +#pragma qt_sync_stop_processing +#endif + +QT_BEGIN_NAMESPACE + +// like std::to_underlying +template +constexpr std::underlying_type_t qToUnderlying(Enum e) noexcept +{ + return static_cast>(e); +} + +QT_END_NAMESPACE + +#endif // QTYPETRAITS_H diff --git a/src/corelib/global/qtypetraits.qdoc b/src/corelib/global/qtypetraits.qdoc new file mode 100644 index 00000000000..e4826942664 --- /dev/null +++ b/src/corelib/global/qtypetraits.qdoc @@ -0,0 +1,11 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only + +/*! + \fn template std::underlying_type_t qToUnderlying(Enum e) + \relates + \since 6.2 + + Converts the enumerator \a e to the equivalent value expressed in its + enumeration's underlying type. +*/