7#include <QtCore/qcompilerdetection.h>
8#include <QtCore/qtypes.h>
9#include <QtCore/qcontainerfwd.h>
14#include <initializer_list>
15#include <QtCore/q20iterator.h>
16#include <QtCore/q20memory.h>
20#include <QtCore/q20type_traits.h>
29QT_BEGIN_INCLUDE_NAMESPACE
31#ifdef __cpp_lib_concepts
32namespace std::ranges {
36template <
typename T, std::size_t E>
37constexpr inline bool enable_borrowed_range<QT_PREPEND_NAMESPACE(QSpan)<T, E>> =
true;
38template <
typename T, std::size_t E>
39constexpr inline bool enable_view<QT_PREPEND_NAMESPACE(QSpan)<T, E>> =
true;
43QT_END_INCLUDE_NAMESPACE
47template <
typename From,
typename To>
57template <
typename T,
std::size_t E>
73template <
typename T,
std::size_t N>
78template <
typename From,
typename To>
80 std::is_convertible<From(*)[], To(*)[]>;
81template <
typename From,
typename To>
85#define MAKE_ADL_TEST(what)
87 template <typename T> using what ## _result = decltype( what (std::declval<T&&>()));
97template <
typename Range>
99template <
typename Range>
101template <
typename Range>
106template <
typename Range>
108template <
typename Range>
132 template <
typename Range,
typename =
void>
134 template <
typename Range>
137 template <
typename Range>
156 template <
typename Range>
160template <
typename T,
std::size_t E>
164 "QSpan only supports extents that fit into the signed size type (qsizetype).");
171 template <
typename S>
190 template <
typename It,
typename Base::
template if_compatible_iterator<It> =
true>
194 Q_ASSERT(count == m_size);
197 template <
typename It,
typename End,
typename Base::
template if_compatible_iterator_and_sentinel<It, End> =
true>
250 template <
typename S>
311template <
typename T,
std::size_t E>
318 Q_ALWAYS_INLINE
constexpr void verify([[maybe_unused]] qsizetype pos = 0,
319 [[maybe_unused]] qsizetype n = 1)
const
322 Q_ASSERT(pos <= size());
324 Q_ASSERT(n <= size() - pos);
327 template <std::size_t N>
328 static constexpr bool subspan_always_succeeds_v = N <= E && E != q20::dynamic_extent;
332#ifdef QT_COMPILER_HAS_LWG3346
372 { verify(idx);
return data()[idx]; }
388 template <
std::size_t Count>
392 static_assert(Count <= E,
393 "Count cannot be larger than the span's extent.");
398 template <
std::size_t Count>
402 static_assert(Count <= E,
403 "Count cannot be larger than the span's extent.");
405 return QSpan<T, Count>{data() + (size() - Count), Count};
408 template <
std::size_t Offset>
412 static_assert(Offset <= E,
413 "Offset cannot be larger than the span's extent.");
416 return QSpan<T>{data() + Offset, qsizetype(size() - Offset)};
418 return QSpan<T, E - Offset>{
data() + Offset, qsizetype(E - Offset)};
421 template <
std::size_t Offset,
std::size_t Count>
424 {
return subspan<Offset>().
template first<Count>(); }
427 [[
nodiscard]]
constexpr QSpan<
T>
last(size_type n)
const { verify(0, n);
return {data() + (size() - n), n}; }
439# define QT_ONLY_IF_DYNAMIC_SPAN(DECL)
440 DECL requires(E == q20::dynamic_extent)
442# define QT_ONLY_IF_DYNAMIC_SPAN(DECL)
443 template <size_t M = E, typename = std::enable_if_t<M == q20::dynamic_extent>> DECL
446 constexpr void slice(size_type pos)
448 { *
this = sliced(pos); }
450 constexpr void slice(size_type pos, size_type n)
452 { *
this = sliced(pos, n); }
454 constexpr void chop(size_type n)
456 { *
this = chopped(n); }
457#undef QT_ONLY_IF_DYNAMIC_SPAN
466 return R{
reinterpret_cast<
const std::byte *>(s
.data()), s.size_bytes()};
469 template <
typename U>
473 template <
typename T2 = T, if_mutable<T2> =
true>
480 return R{
reinterpret_cast<
std::byte *>(s
.data()), s.size_bytes()};
485template <
class It,
class EndOrSize>
486QSpan(It, EndOrSize) -> QSpan<std::remove_reference_t<q20::iter_reference_t<It>>>;
487template <
class T,
std::size_t N>
489template <
class T,
std::size_t N>
491template <
class T,
std::size_t N>
494QSpan(R&&) -> QSpan<std::remove_reference_t<QSpanPrivate::range_reference_t<R>>>;
QDataStream & operator>>(QDataStream &in, QByteArray &ba)
Reads a byte array into ba from the stream in and returns a reference to the stream.
quint16 qChecksum(QByteArrayView data, Qt::ChecksumType standard)
static QLatin1StringView scriptToCode(QLocale::Script script)
QString toUpper(const QString &str, bool *ok) const
static const QLocalePrivate * get(const QLocale &l)
QString toLower(const QString &str, bool *ok) const
quint16 languageId() const
static QLocale::Language codeToLanguage(QStringView code, QLocale::LanguageCodeTypes codeTypes=QLocale::AnyLanguageCode) noexcept
const QLocaleData *const m_data
QLatin1StringView scriptCode() const
QLocale::MeasurementSystem measurementSystem() const
quint16 territoryId() const
static QLatin1StringView territoryToCode(QLocale::Territory territory)
static QLocale::Territory codeToTerritory(QStringView code) noexcept
static std::array< char, 4 > languageToCode(QLocale::Language language, QLocale::LanguageCodeTypes codeTypes=QLocale::AnyLanguageCode)
static QLocale::Script codeToScript(QStringView code) noexcept
QLocale::NumberOptions m_numberOptions
QLatin1StringView territoryCode() const
constexpr QLocalePrivate(const QLocaleData *data, qsizetype index, QLocale::NumberOptions numberOptions=QLocale::DefaultNumberOptions, int refs=0)
std::array< char, 4 > languageCode(QLocale::LanguageCodeTypes codeTypes=QLocale::AnyLanguageCode) const
static QBasicAtomicInt s_generation
QByteArray bcp47Name(char separator='-') const
constexpr QSpanBase(It first, qsizetype count)
static constexpr qsizetype m_size
constexpr QSpanBase(It first, End last)
constexpr bool empty() const noexcept
constexpr pointer data() const noexcept
static constexpr std::size_t extent
constexpr reverse_iterator rbegin() const noexcept
constexpr reference front() const
constexpr QSpan< T > sliced(size_type pos, size_type n) const
constexpr QSpan< T > sliced(size_type pos) const
constexpr size_type size() const noexcept
const_pointer const_iterator
constexpr iterator end() const noexcept
constexpr const_iterator cbegin() const noexcept
constexpr QSpan< T > subspan(size_type pos, size_type n) const
constexpr const_iterator cend() const noexcept
constexpr bool isEmpty() const noexcept
constexpr reverse_iterator rend() const noexcept
constexpr QSpan< T, Count > last() const noexcept(subspan_always_succeeds_v< Count >)
constexpr QSpan< T > last(size_type n) const
constexpr const_reverse_iterator crend() const noexcept
friend QSpan< const std::byte, E==q20::dynamic_extent ? q20::dynamic_extent :E *sizeof(T)> as_bytes(QSpan s) noexcept
constexpr size_type size_bytes() const noexcept
std::reverse_iterator< const_iterator > const_reverse_iterator
constexpr const_reverse_iterator crbegin() const noexcept
constexpr reference operator[](size_type idx) const
constexpr QSpan< T > first(size_type n) const
constexpr reference back() const
constexpr QSpan< T > subspan(size_type pos) const
constexpr auto subspan() const noexcept(subspan_always_succeeds_v< Offset+Count >)
constexpr QSpan< T, Count > first() const noexcept(subspan_always_succeeds_v< Count >)
const T & const_reference
std::reverse_iterator< iterator > reverse_iterator
constexpr QSpan< T > chopped(size_type n) const
friend QSpan< std::byte, E==q20::dynamic_extent ? q20::dynamic_extent :E *sizeof(T)> as_writable_bytes(QSpan s) noexcept
constexpr iterator begin() const noexcept
constexpr auto subspan() const noexcept(subspan_always_succeeds_v< Offset >)
qsizetype fallbackLocaleIndex() const
@ StringToAlternateQuotation
@ StandaloneMonthNameLong
@ StandaloneDayNameNarrow
@ StandaloneMonthNameNarrow
@ StringToStandardQuotation
@ StandaloneMonthNameShort
virtual QLocale fallbackLocale() const
virtual QVariant query(QueryType type, QVariant &&in=QVariant()) const
AdlTester::size_result< Range > adl_size(Range &&r)
std::conditional_t< std::is_const_v< From >, const To &, To & > const_propagated(To &in)
decltype(QSpanPrivate::adl_begin(std::declval< Range & >())) iterator_t
AdlTester::data_result< Range > adl_data(Range &&r)
std::is_convertible< From(*)[], To(*)[]> is_qualification_conversion
AdlTester::begin_result< Range > adl_begin(Range &&r)
constexpr bool is_qualification_conversion_v
constexpr char ascii_space_chars[]
constexpr auto makeCharacterSetMatch() noexcept
constexpr auto dynamic_extent
static constexpr bool isLowerCaseAscii(char c)
static const quint16 crc_tbl[16]
QByteArray qCompress(const uchar *data, qsizetype nbytes, int compressionLevel)
static Q_DECL_COLD_FUNCTION const char * zlibOpAsString(ZLibOp op)
static QByteArray toCase_template(T &input, uchar(*lookup)(uchar))
static void q_fromPercentEncoding(QByteArray *ba, char percent)
int qstrnicmp(const char *str1, qsizetype len1, const char *str2, qsizetype len2)
static qsizetype lastIndexOfHelper(const char *haystack, qsizetype l, const char *needle, qsizetype ol, qsizetype from)
static constexpr bool isUpperCaseAscii(char c)
static QByteArray xxflate(ZLibOp op, QArrayDataPointer< char > out, QByteArrayView input, qxp::function_ref< int(z_stream *) const > init, qxp::function_ref< int(z_stream *, size_t) const > processChunk, qxp::function_ref< void(z_stream *) const > deinit)
static constexpr uchar asciiLower(uchar c)
static qsizetype countCharHelper(QByteArrayView haystack, char needle) noexcept
static constexpr uchar asciiUpper(uchar c)
Q_CORE_EXPORT char * qstrncpy(char *dst, const char *src, size_t len)
Q_CORE_EXPORT int qstrnicmp(const char *, const char *, size_t len)
Q_CORE_EXPORT int qstricmp(const char *, const char *)
Q_CORE_EXPORT char * qstrdup(const char *)
Q_CORE_EXPORT char * qstrcpy(char *dst, const char *src)
Q_DECL_PURE_FUNCTION Q_CORE_EXPORT const void * qmemrchr(const void *s, int needle, size_t n) noexcept
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
bool qt_splitLocaleName(QStringView name, QStringView *lang=nullptr, QStringView *script=nullptr, QStringView *cntry=nullptr) noexcept
Q_DECLARE_TYPEINFO(QLocaleData::GroupSizes, Q_PRIMITIVE_TYPE)
Q_DECLARE_TYPEINFO(QLocaleId, Q_PRIMITIVE_TYPE)
qsizetype qt_repeatCount(QStringView s) noexcept
constexpr bool ascii_isspace(uchar c) noexcept
#define ForEachQLocaleRange(X)
QString qt_readEscapedFormatString(QStringView format, qsizetype *idx)
constexpr size_t qHash(const QSize &s, size_t seed=0) noexcept
#define MAKE_ADL_TEST(what)
QSpan(const std::array< T, N > &) -> QSpan< const T, N >
#define QT_ONLY_IF_DYNAMIC_SPAN(DECL)
QSpan(T(&)[N]) -> QSpan< T, N >
QSpan(std::array< T, N > &) -> QSpan< T, N >
qregisteruint mask[Extent]
static constexpr int WordBits
static constexpr int MaxRange
constexpr auto maskLocation(uchar c) const noexcept
constexpr QCharacterSetMatch(std::string_view set) noexcept
constexpr bool matches(uchar c) const noexcept
QStringView viewListEntry(const char16_t *table, qsizetype index) const
char32_t ucsFirst(const char16_t *table) const
QString getData(const char16_t *table) const
QString getListEntry(const char16_t *table, qsizetype index) const
QStringView viewData(const char16_t *table) const
void setZero(QStringView zero)
bool fractionalIsGroup() const
const GroupSizes & groupSizes() const
bool isValid(NumberMode mode) const
const GroupSizes grouping
qint8 digitValue(char32_t digit) const
QString positiveSign() const
static float convertDoubleToFloat(double d, bool *ok)
QString groupSeparator() const
QSimpleParsedNumber< qint64 > stringToLongLong(QStringView str, int base, QLocale::NumberOptions options) const
Q_AUTOTEST_EXPORT char32_t zeroUcs() const
QString zeroDigit() const
bool numberToCLocale(QStringView s, QLocale::NumberOptions number_options, NumberMode mode, CharBuff *result) const
QString decimalPoint() const
QString doubleToString(double d, int precision=-1, DoubleForm form=DFSignificantDigits, int width=-1, unsigned flags=NoFlags) const
static Q_AUTOTEST_EXPORT bool allLocaleDataRows(bool(*check)(qsizetype, const QLocaleData &))
QString listSeparator() const
static QSimpleParsedNumber< quint64 > bytearrayToUnsLongLong(QByteArrayView num, int base)
QString percentSign() const
double stringToDouble(QStringView str, bool *ok, QLocale::NumberOptions options) const
QString longLongToString(qint64 l, int precision=-1, int base=10, int width=-1, unsigned flags=NoFlags) const
quint8 m_first_day_of_week
quint8 m_currency_rounding
QString exponentSeparator() const
QString negativeSign() const
QSimpleParsedNumber< quint64 > stringToUnsLongLong(QStringView str, int base, QLocale::NumberOptions options) const
QString unsLongLongToString(quint64 l, int precision=-1, int base=10, int width=-1, unsigned flags=NoFlags) const
QLocaleId withLikelySubtagsAdded() const noexcept
Fill in blank fields of a locale ID.
QLocaleId withLikelySubtagsRemoved() const noexcept
bool operator==(QLocaleId other) const noexcept
bool matchesAll() const noexcept
bool isValid() const noexcept
bool operator!=(QLocaleId other) const noexcept
bool acceptScriptTerritory(QLocaleId other) const noexcept
bool acceptLanguage(quint16 lang) const noexcept
CurrencyToStringArgument(const QVariant &v, const QString &s)
CurrencyToStringArgument()