Extract header qtypetraits.h from qglobal.h

Task-number: QTBUG-99313
Change-Id: I6cb76607213ca5d64dec669a39e8a59e13b21497
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Sona Kurazyan 2022-08-22 16:00:06 +02:00
parent 9c706e2567
commit d9544394b0
5 changed files with 40 additions and 16 deletions

View File

@ -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

View File

@ -2797,15 +2797,6 @@ void qAbort()
that qExchange() returns a non-const object, so Qt containers may detach.
*/
/*!
\fn template <typename Enum> std::underlying_type_t<Enum> qToUnderlying(Enum e)
\relates <QtGlobal>
\since 6.2
Converts the enumerator \a e to the equivalent value expressed in its
enumeration's underlying type.
*/
/*!
\macro Q_LIKELY(expr)
\relates <QtGlobal>

View File

@ -158,13 +158,6 @@ noexcept(std::conjunction_v<std::is_nothrow_move_constructible<T>, std::is_nothr
return old;
}
// like std::to_underlying
template <typename Enum>
constexpr std::underlying_type_t<Enum> qToUnderlying(Enum e) noexcept
{
return static_cast<std::underlying_type_t<Enum>>(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 <QtCore/qtdeprecationmarkers.h>
#include <QtCore/qtranslation.h>
#include <QtCore/qtresource.h>
#include <QtCore/qtypetraits.h>
#include <QtCore/qversiontagging.h>
#endif /* __cplusplus */

View File

@ -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 <QtCore/qtconfigmacros.h>
#include <type_traits>
#if 0
#pragma qt_class(QTypeTraits)
#pragma qt_sync_stop_processing
#endif
QT_BEGIN_NAMESPACE
// like std::to_underlying
template <typename Enum>
constexpr std::underlying_type_t<Enum> qToUnderlying(Enum e) noexcept
{
return static_cast<std::underlying_type_t<Enum>>(e);
}
QT_END_NAMESPACE
#endif // QTYPETRAITS_H

View File

@ -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 <typename Enum> std::underlying_type_t<Enum> qToUnderlying(Enum e)
\relates <QTypeTraits>
\since 6.2
Converts the enumerator \a e to the equivalent value expressed in its
enumeration's underlying type.
*/