Make is_standard_or_extended_integer_type more robust
Instead of listing every standard integer type manually, and then only handling q(u)int128 as extended integer types, let the compiler decide what's integral, and only exclude bool and the char types manually. This more faithfully represents the letter of https://eel.is/c++draft/basic.fundamental#1 and means we don't need to include qtypes.h anymore. Amends a313caca239638b384018aec18906de44aab2171. Enabled by fixing QTBUG-119901, so that we can rely on extended integer types to be correctly identified by std::is_integral. Add a check for qint128 being is_standard_or_extended_integer_type to tst_qglobal.cpp's block of qint128 sanity checks. Task-number: QTBUG-119901 Task-number: QTBUG-105462 Change-Id: I082d76ca2b89d7e5d1bbace98c57a44eac1117d9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
parent
2f317b41ea
commit
e8f468c88f
@ -6,7 +6,6 @@
|
||||
|
||||
#include <QtCore/qtconfigmacros.h>
|
||||
#include <QtCore/qtdeprecationmarkers.h>
|
||||
#include <QtCore/qtypes.h>
|
||||
|
||||
#include <optional>
|
||||
#include <tuple>
|
||||
@ -65,33 +64,20 @@ template <auto T> struct value_dependent_false : std::false_type {};
|
||||
|
||||
// helper detects standard integer types and some of extended integer types,
|
||||
// see https://eel.is/c++draft/basic.fundamental#1
|
||||
template <typename T> struct is_standard_or_extended_integer_type_helper : std::false_type {};
|
||||
template <>
|
||||
struct is_standard_or_extended_integer_type_helper<signed char> : std::true_type {};
|
||||
template <>
|
||||
struct is_standard_or_extended_integer_type_helper<unsigned char> : std::true_type {};
|
||||
template <>
|
||||
struct is_standard_or_extended_integer_type_helper<signed short int> : std::true_type {};
|
||||
template <>
|
||||
struct is_standard_or_extended_integer_type_helper<unsigned short int> : std::true_type {};
|
||||
template <>
|
||||
struct is_standard_or_extended_integer_type_helper<signed int> : std::true_type {};
|
||||
template <>
|
||||
struct is_standard_or_extended_integer_type_helper<unsigned int> : std::true_type {};
|
||||
template <>
|
||||
struct is_standard_or_extended_integer_type_helper<signed long int> : std::true_type {};
|
||||
template <>
|
||||
struct is_standard_or_extended_integer_type_helper<unsigned long int> : std::true_type {};
|
||||
template <>
|
||||
struct is_standard_or_extended_integer_type_helper<signed long long int> : std::true_type {};
|
||||
template <>
|
||||
struct is_standard_or_extended_integer_type_helper<unsigned long long int> : std::true_type {};
|
||||
#ifdef QT_SUPPORTS_INT128
|
||||
template <>
|
||||
struct is_standard_or_extended_integer_type_helper<qint128> : std::true_type {};
|
||||
template <>
|
||||
struct is_standard_or_extended_integer_type_helper<quint128> : std::true_type {};
|
||||
#endif // QT_SUPPORTS_INT128
|
||||
template <typename T> struct is_standard_or_extended_integer_type_helper : std::is_integral<T> {};
|
||||
// these are integral, but not considered standard or extended integer types
|
||||
// https://eel.is/c++draft/basic.fundamental#11:
|
||||
#define QSEIT_EXCLUDE(X) \
|
||||
template <> struct is_standard_or_extended_integer_type_helper<X> : std::false_type {}
|
||||
QSEIT_EXCLUDE(bool);
|
||||
QSEIT_EXCLUDE(char);
|
||||
#ifdef __cpp_char8_t
|
||||
QSEIT_EXCLUDE(char8_t);
|
||||
#endif
|
||||
QSEIT_EXCLUDE(char16_t);
|
||||
QSEIT_EXCLUDE(char32_t);
|
||||
QSEIT_EXCLUDE(wchar_t);
|
||||
#undef QSEIT_EXCLUDE
|
||||
template <typename T>
|
||||
struct is_standard_or_extended_integer_type : is_standard_or_extended_integer_type_helper<std::remove_cv_t<T>> {};
|
||||
template <typename T>
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <QLatin1String>
|
||||
#include <QString>
|
||||
#include <QtVersion>
|
||||
#include <QtCore/qttypetraits.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
@ -22,6 +23,8 @@
|
||||
static_assert(std::is_signed_v<qint128>);
|
||||
static_assert(std::is_integral_v<qint128>);
|
||||
static_assert(std::is_integral_v<quint128>);
|
||||
static_assert(QtPrivate::is_standard_or_extended_integer_type_v<qint128>);
|
||||
static_assert(QtPrivate::is_standard_or_extended_integer_type_v<quint128>);
|
||||
static_assert(std::numeric_limits<qint128>::is_signed);
|
||||
static_assert(std::numeric_limits<qint128>::is_specialized);
|
||||
static_assert(std::numeric_limits<quint128>::is_specialized);
|
||||
|
Loading…
x
Reference in New Issue
Block a user