43 #include <QtCore/qglobal.h>
45 #if __has_include(<bit>) && __cplusplus > 201703L
55 template <
typename ForwardIterator>
64 template <
typename Container>
78 # if (defined __apple_build_version__ && __clang_major__ >= 7) || (Q_CC_CLANG >= 307)
79 # define QT_HAS_CONSTEXPR_BUILTINS
81 #elif defined(Q_CC_MSVC) && !defined(Q_CC_INTEL) && !defined(Q_PROCESSOR_ARM)
82 # define QT_HAS_CONSTEXPR_BUILTINS
83 #elif defined(Q_CC_GNU)
84 # define QT_HAS_CONSTEXPR_BUILTINS
87 #if defined QT_HAS_CONSTEXPR_BUILTINS
88 #if defined(Q_CC_GNU) || defined(Q_CC_CLANG)
89 # define QT_HAS_BUILTIN_CTZS
90 constexpr Q_ALWAYS_INLINE
uint qt_builtin_ctzs(
quint16 v) noexcept
92 # if __has_builtin(__builtin_ctzs)
93 return __builtin_ctzs(
v);
95 return __builtin_ctz(
v);
98 #define QT_HAS_BUILTIN_CLZS
99 constexpr Q_ALWAYS_INLINE
uint qt_builtin_clzs(
quint16 v) noexcept
101 # if __has_builtin(__builtin_clzs)
102 return __builtin_clzs(
v);
104 return __builtin_clz(
v) - 16U;
107 #define QT_HAS_BUILTIN_CTZ
108 constexpr Q_ALWAYS_INLINE
uint qt_builtin_ctz(
quint32 v) noexcept
110 return __builtin_ctz(
v);
112 #define QT_HAS_BUILTIN_CLZ
113 constexpr Q_ALWAYS_INLINE
uint qt_builtin_clz(
quint32 v) noexcept
115 return __builtin_clz(
v);
117 #define QT_HAS_BUILTIN_CTZLL
118 constexpr Q_ALWAYS_INLINE
uint qt_builtin_ctzll(
quint64 v) noexcept
120 return __builtin_ctzll(
v);
122 #define QT_HAS_BUILTIN_CLZLL
123 constexpr Q_ALWAYS_INLINE
uint qt_builtin_clzll(
quint64 v) noexcept
125 return __builtin_clzll(
v);
127 #define QALGORITHMS_USE_BUILTIN_POPCOUNT
128 constexpr Q_ALWAYS_INLINE
uint qt_builtin_popcount(
quint32 v) noexcept
130 return __builtin_popcount(
v);
132 constexpr Q_ALWAYS_INLINE
uint qt_builtin_popcount(
quint8 v) noexcept
134 return __builtin_popcount(
v);
136 constexpr Q_ALWAYS_INLINE
uint qt_builtin_popcount(
quint16 v) noexcept
138 return __builtin_popcount(
v);
140 #define QALGORITHMS_USE_BUILTIN_POPCOUNTLL
141 constexpr Q_ALWAYS_INLINE
uint qt_builtin_popcountll(
quint64 v) noexcept
143 return __builtin_popcountll(
v);
145 #elif defined(Q_CC_MSVC) && !defined(Q_PROCESSOR_ARM)
146 #define QT_HAS_BUILTIN_CTZ
147 Q_ALWAYS_INLINE
unsigned long qt_builtin_ctz(
quint32 val)
153 #define QT_HAS_BUILTIN_CLZ
154 Q_ALWAYS_INLINE
unsigned long qt_builtin_clz(
quint32 val)
164 #if Q_PROCESSOR_WORDSIZE == 8
166 #define QT_HAS_BUILTIN_CTZLL
167 Q_ALWAYS_INLINE
unsigned long qt_builtin_ctzll(
quint64 val)
174 #define QT_HAS_BUILTIN_CLZLL
175 Q_ALWAYS_INLINE
unsigned long qt_builtin_clzll(
quint64 val)
184 # define QT_HAS_BUILTIN_CTZS
185 Q_ALWAYS_INLINE
uint qt_builtin_ctzs(
quint16 v) noexcept
187 return qt_builtin_ctz(
v);
189 #define QT_HAS_BUILTIN_CLZS
190 Q_ALWAYS_INLINE
uint qt_builtin_clzs(
quint16 v) noexcept
192 return qt_builtin_clz(
v) - 16U;
204 #if defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L
206 #elif defined(__AVX__) || defined(__SSE4_2__) || defined(__POPCNT__)
207 #define QT_POPCOUNT_CONSTEXPR
208 #define QT_POPCOUNT_RELAXED_CONSTEXPR
209 #define QALGORITHMS_USE_BUILTIN_POPCOUNT
210 #define QALGORITHMS_USE_BUILTIN_POPCOUNTLL
211 Q_ALWAYS_INLINE
uint qt_builtin_popcount(
quint32 v) noexcept
215 Q_ALWAYS_INLINE
uint qt_builtin_popcount(
quint8 v) noexcept
217 return __popcnt16(
v);
219 Q_ALWAYS_INLINE
uint qt_builtin_popcount(
quint16 v) noexcept
221 return __popcnt16(
v);
223 Q_ALWAYS_INLINE
uint qt_builtin_popcountll(
quint64 v) noexcept
225 #if Q_PROCESSOR_WORDSIZE == 8
226 return __popcnt64(
v);
237 #ifndef QT_POPCOUNT_CONSTEXPR
238 #define QT_POPCOUNT_CONSTEXPR constexpr
239 #define QT_POPCOUNT_RELAXED_CONSTEXPR constexpr
246 #if defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L
247 return std::popcount(
v);
248 #elif defined QALGORITHMS_USE_BUILTIN_POPCOUNT
249 return QAlgorithmsPrivate::qt_builtin_popcount(
v);
261 #if defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L
262 return std::popcount(
v);
263 #elif defined QALGORITHMS_USE_BUILTIN_POPCOUNT
264 return QAlgorithmsPrivate::qt_builtin_popcount(
v);
273 #if defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L
274 return std::popcount(
v);
275 #elif defined QALGORITHMS_USE_BUILTIN_POPCOUNT
276 return QAlgorithmsPrivate::qt_builtin_popcount(
v);
286 #if defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L
287 return std::popcount(
v);
288 #elif defined QALGORITHMS_USE_BUILTIN_POPCOUNTLL
289 return QAlgorithmsPrivate::qt_builtin_popcountll(
v);
306 #if defined(QALGORITHMS_USE_BUILTIN_POPCOUNT)
307 #undef QALGORITHMS_USE_BUILTIN_POPCOUNT
309 #undef QT_POPCOUNT_CONSTEXPR
318 if (
v & 0x0000FFFF)
c -= 16;
319 if (
v & 0x00FF00FF)
c -= 8;
320 if (
v & 0x0F0F0F0F)
c -= 4;
321 if (
v & 0x33333333)
c -= 2;
322 if (
v & 0x55555555)
c -= 1;
338 if (
v & 0x0000000F)
c -= 4;
339 if (
v & 0x00000033)
c -= 2;
340 if (
v & 0x00000055)
c -= 1;
349 if (
v & 0x000000FF)
c -= 8;
350 if (
v & 0x00000F0F)
c -= 4;
351 if (
v & 0x00003333)
c -= 2;
352 if (
v & 0x00005555)
c -= 1;
364 #if defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L
365 return std::countr_zero(
v);
366 #elif defined(QT_HAS_BUILTIN_CTZ)
367 return v ? QAlgorithmsPrivate::qt_builtin_ctz(
v) : 32U;
375 #if defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L
376 return std::countr_zero(
v);
377 #elif defined(QT_HAS_BUILTIN_CTZ)
378 return v ? QAlgorithmsPrivate::qt_builtin_ctz(
v) : 8U;
386 #if defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L
387 return std::countr_zero(
v);
388 #elif defined(QT_HAS_BUILTIN_CTZS)
389 return v ? QAlgorithmsPrivate::qt_builtin_ctzs(
v) : 16U;
397 #if defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L
398 return std::countr_zero(
v);
399 #elif defined(QT_HAS_BUILTIN_CTZLL)
400 return v ? QAlgorithmsPrivate::qt_builtin_ctzll(
v) : 64;
413 #if defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L
414 return std::countl_zero(
v);
415 #elif defined(QT_HAS_BUILTIN_CLZ)
416 return v ? QAlgorithmsPrivate::qt_builtin_clz(
v) : 32U;
430 #if defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L
431 return std::countl_zero(
v);
432 #elif defined(QT_HAS_BUILTIN_CLZ)
433 return v ? QAlgorithmsPrivate::qt_builtin_clz(
v)-24U : 8U;
444 #if defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L
445 return std::countl_zero(
v);
446 #elif defined(QT_HAS_BUILTIN_CLZS)
447 return v ? QAlgorithmsPrivate::qt_builtin_clzs(
v) : 16U;
459 #if defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L
460 return std::countl_zero(
v);
461 #elif defined(QT_HAS_BUILTIN_CLZLL)
462 return v ? QAlgorithmsPrivate::qt_builtin_clzll(
v) : 64U;
479 #undef QT_POPCOUNT_RELAXED_CONSTEXPR
constexpr uint qConstexprCountTrailingZeroBits(quint32 v) noexcept
QT_BEGIN_NAMESPACE Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
QT_POPCOUNT_RELAXED_CONSTEXPR uint qCountLeadingZeroBits(quint32 v) noexcept
constexpr uint qCountTrailingZeroBits(quint32 v) noexcept
#define QT_POPCOUNT_CONSTEXPR
#define QT_POPCOUNT_RELAXED_CONSTEXPR
Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR uint qPopulationCount(quint32 v) noexcept
#define Q_DECL_CONST_FUNCTION
unsigned long long quint64
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)