8#include <QtCore/qcompilerdetection.h>
9#include <QtCore/qtypes.h>
10#include <QtCore/qcontainerfwd.h>
15#include <initializer_list>
16#include <QtCore/q20iterator.h>
17#include <QtCore/q20memory.h>
21#include <QtCore/q20type_traits.h>
30QT_BEGIN_INCLUDE_NAMESPACE
32#ifdef __cpp_lib_concepts
33namespace std::ranges {
37template <
typename T, std::size_t E>
38constexpr inline bool enable_borrowed_range<QT_PREPEND_NAMESPACE(QSpan)<T, E>> =
true;
39template <
typename T, std::size_t E>
40constexpr inline bool enable_view<QT_PREPEND_NAMESPACE(QSpan)<T, E>> =
true;
44QT_END_INCLUDE_NAMESPACE
48template <
typename From,
typename To>
58template <
typename T,
std::size_t E>
74template <
typename T,
std::size_t N>
79template <
typename From,
typename To>
81 std::is_convertible<From(*)[], To(*)[]>;
82template <
typename From,
typename To>
86#define MAKE_ADL_TEST(what)
88 template <typename T> using what ## _result = decltype( what (std::declval<T&&>()));
98template <
typename Range>
100template <
typename Range>
102template <
typename Range>
107template <
typename Range>
109template <
typename Range>
133 template <
typename Range,
typename =
void>
135 template <
typename Range>
138 template <
typename Range>
157 template <
typename Range>
161template <
typename T,
std::size_t E>
165 "QSpan only supports extents that fit into the signed size type (qsizetype).");
172 template <
typename S>
191 template <
typename It,
typename Base::
template if_compatible_iterator<It> =
true>
195 Q_PRE(count == m_size);
198 template <
typename It,
typename End,
typename Base::
template if_compatible_iterator_and_sentinel<It, End> =
true>
251 template <
typename S>
315template <
typename T,
std::size_t E>
322 Q_ALWAYS_INLINE
constexpr void verify([[maybe_unused]] qsizetype pos = 0,
323 [[maybe_unused]] qsizetype n = 1)
const
326 Q_ASSERT(pos <= size());
328 Q_ASSERT(n <= size() - pos);
331 template <std::size_t N>
332 static constexpr bool subspan_always_succeeds_v = N <= E && E != q20::dynamic_extent;
336#ifdef QT_COMPILER_HAS_LWG3346
370 [[nodiscard]]
constexpr size_type size()
const noexcept {
return this->m_size; }
372 [[nodiscard]]
constexpr bool empty()
const noexcept {
return size() == 0; }
376 { verify(idx);
return data()[idx]; }
378 [[nodiscard]]
constexpr reference back()
const { verify();
return data()[size() - 1]; }
379 [[nodiscard]]
constexpr pointer data()
const noexcept {
return this->m_data; }
383 [[nodiscard]]
constexpr iterator end()
const noexcept {
return data() + size(); }
392 template <
std::size_t Count>
396 static_assert(Count <= E,
397 "Count cannot be larger than the span's extent.");
402 template <
std::size_t Count>
406 static_assert(Count <= E,
407 "Count cannot be larger than the span's extent.");
409 return QSpan<T, Count>{data() + (size() - Count), Count};
412 template <
std::size_t Offset>
416 static_assert(Offset <= E,
417 "Offset cannot be larger than the span's extent.");
420 return QSpan<T>{data() + Offset, qsizetype(size() - Offset)};
422 return QSpan<T, E - Offset>{
data() + Offset, qsizetype(E - Offset)};
425 template <
std::size_t Offset,
std::size_t Count>
428 {
return subspan<Offset>().
template first<Count>(); }
431 [[nodiscard]]
constexpr QSpan<
T>
last(size_type n)
const { verify(0, n);
return {data() + (size() - n), n}; }
432 [[nodiscard]]
constexpr QSpan<
T>
subspan(size_type pos)
const { verify(pos, 0);
return {data() + pos, size() - pos}; }
433 [[nodiscard]]
constexpr QSpan<
T>
subspan(size_type pos, size_type n)
const {
return subspan(pos).first(n); }
436 [[nodiscard]]
constexpr bool isEmpty()
const noexcept {
return empty(); }
438 [[nodiscard]]
constexpr QSpan<
T>
sliced(size_type pos)
const {
return subspan(pos); }
439 [[nodiscard]]
constexpr QSpan<
T>
sliced(size_type pos, size_type n)
const {
return subspan(pos, n); }
440 [[nodiscard]]
constexpr QSpan<
T>
chopped(size_type n)
const { verify(0, n);
return first(size() - n); }
443# define QT_ONLY_IF_DYNAMIC_SPAN(DECL)
444 DECL requires(E == q20::dynamic_extent)
446# define QT_ONLY_IF_DYNAMIC_SPAN(DECL)
447 template <size_t M = E, typename = std::enable_if_t<M == q20::dynamic_extent>> DECL
450 constexpr void slice(size_type pos)
452 { *
this = sliced(pos); }
454 constexpr void slice(size_type pos, size_type n)
456 { *
this = sliced(pos, n); }
458 constexpr void chop(size_type n)
460 { *
this = chopped(n); }
461#undef QT_ONLY_IF_DYNAMIC_SPAN
470 return R{
reinterpret_cast<
const std::byte *>(s
.data()), s.size_bytes()};
473 template <
typename U>
477 template <
typename T2 = T, if_mutable<T2> =
true>
484 return R{
reinterpret_cast<
std::byte *>(s
.data()), s.size_bytes()};
489template <
class It,
class EndOrSize>
490QSpan(It, EndOrSize) -> QSpan<std::remove_reference_t<q20::iter_reference_t<It>>>;
491template <
class T,
std::size_t N>
493template <
class T,
std::size_t N>
495template <
class T,
std::size_t N>
498QSpan(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 >)
\macro QT_RESTRICTED_CAST_FROM_ASCII
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)
AdlTester::begin_result< Range > adl_begin(Range &&r)
constexpr bool is_qualification_conversion_v
std::is_convertible< From(*)[], To(*)[]> is_qualification_conversion
Combined button and popup list for selecting options.
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(const QByteArray &input, QByteArray *rvalue, uchar(*lookup)(uchar))
static qsizetype q_fromPercentEncoding(QByteArrayView src, char percent, QSpan< char > buffer)
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 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(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
Descriptor for a digit sequence within a text.
qsizetype size() const
Returns the number of ASCII characters describing the digit sequence.
DigitSequence sliced(qsizetype from, qsizetype count) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
DigitSequence & operator=(const DigitSequence &)=default
QStringView used(const QStringView text) const
Returns the slice of text described by this digit sequence.
Q_DECLARE_FLAGS(Options, Option)
bool hasSign() const
Returns true precisely if the digit sequence parsed includes a leading sign.
bool isEmpty() const
Returns true precisely if this digit sequence represents nothing.
DigitSequence first(qsizetype count) const
Returns a DigitSequence describing a prefix of this.
void transcribeTo(CharBuff *buff) const
Transcribes the ASCII form of this digit sequence to buff.
DigitSequence(DigitSequence &&)=default
DigitSequence & operator=(DigitSequence &&)=default
DigitSequence sliced(qsizetype from) const
Returns a DigitSequence describing a tail of this.
QStringView used(const QStringView text, qsizetype from) const
DigitSequence last(qsizetype count) const
Returns a DigitSequence describing a tail of this.
qsizetype endIndex() const
DigitSequence(const DigitSequence &)=default
void setZero(QStringView zero)
bool fractionalIsGroup() const
qsizetype zeroWidth() 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
Returns a DigitSequence describing some portion of text starting at from.
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
DigitSequence digitSequence(QStringView text, DigitSequence::Options flags=DigitSequence::Option::Default, qsizetype from=0) 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
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()