QSpan Class | Qt Core (original) (raw)
Member Function Documentation
[default]
QSpan::QSpan(QSpan<T, E> &&other)
[default]
QSpan::QSpan(const QSpan<T, E> &other)
[default]
QSpan<T, E> &QSpan::operator=(QSpan<T, E> &&other)
[default]
QSpan<T, E> &QSpan::operator=(const QSpan<T, E> &other)
[default]
QSpan::~QSpan()
These Special Member Functions are implicitly-defined.
Note: Moves are equivalent to copies. Only data() and size() are copied from span to span, not the referenced data.
[constexpr noexcept]
template <typename S, size_t N, QSpan<T, E>::if_qualification_conversion = true> QSpan::QSpan(const std::array<S, N> &arr)
[constexpr noexcept]
template <size_t N> QSpan::QSpan(q20::type_identity_t<T> (&)[N] arr)
[constexpr noexcept]
template <typename S, size_t N, QSpan<T, E>::if_qualification_conversion = true> QSpan::QSpan(std::array<S, N> &arr)
Constructs a QSpan referencing the data in the supplied array arr.
Constraints
Participates in overload resolution only if
- either
N
or extent arestd::dynamic_extent
or otherwise extent==
N
- and either
S
orconst S
are the same asT
.
[constexpr noexcept]
template <typename S, size_t N, QSpan<T, E>::if_qualification_conversion = true> QSpan::QSpan(QSpan<S, N> other)
[constexpr noexcept]
template <typename S, size_t N, QSpan<T, E>::if_qualification_conversion = true> QSpan::QSpan(std::span<S, N> other)
Constructs a QSpan referencing the data in the supplied span other.
Constraints
Participates in overload resolution only if
- either
N
or extent arestd::dynamic_extent
or extent==
N
- and either
S
orconst S
are the same asT
.
[constexpr noexcept]
auto QSpan::empty() const
[constexpr noexcept]
auto QSpan::isEmpty() const
Returns whether the span is empty, that is, whether size() == 0
.
These functions do the same thing: empty() is provided for STL compatibility and isEmpty() is provided for Qt compatibility.
See also size() and size_bytes().
[constexpr]
auto QSpan::sliced(QSpan<T, E>::size_type pos) const
[constexpr]
auto QSpan::subspan(QSpan<T, E>::size_type pos) const
Returns a variable-sized span of size size() - pos
referencing the remainder of this span after dropping the first pos elements.
pos must be non-negative.
This span must hold at least pos elements (E
>= pos and size() >= pos), otherwise the behavior is undefined.
These functions do the same thing: subspan() is provided for STL compatibility and sliced() is provided for Qt compatibility.
See also subspan(), first(QSpan<T,E>::size_type), last(QSpan<T,E>::size_type), chopped(), and slice().
[constexpr]
auto QSpan::sliced(QSpan<T, E>::size_type pos, QSpan<T, E>::size_type n) const
[constexpr]
auto QSpan::subspan(QSpan<T, E>::size_type pos, QSpan<T, E>::size_type n) const
Returns a variable-sized span of size n referencing the n elements of this span starting at pos.
Both pos and n must be non-negative.
This span must hold at least pos + n
elements (E
>= pos + n
and size() >= pos + n
), otherwise the behavior is undefined.
These functions do the same thing: subspan() is provided for STL compatibility and sliced() is provided for Qt compatibility.
See also subspan(), first(QSpan<T,E>::size_type), last(QSpan<T,E>::size_type), chopped(), and slice().
[default]
QSpan::QSpan()
Default constructor.
This constructor is only present if E
is either zero (0) or std::dynamic_extent
. In other words: only fixed-zero-sized or variable-sized spans are default-constructible.
See also extent and Variable-Size and Fixed-Size Spans.
[constexpr]
template <typename Range, QSpan<T, E>::if_compatible_range = true> QSpan::QSpan(Range &&r)
Constructs a QSpan referencing the data in the supplied range r.
Constraints
Participates in overload resolution only if Range
is a compatible range.
[constexpr]
QSpan::QSpan(std::initializer_list<QSpan<T, E>::value_type> il)
Constructs a QSpan referencing the data in the supplied initializer list il.
Note: This constructor is noexcept
only if E
is std::dynamic_extent
.
Note: If E
is not std::dynamic_extent
and the size of il is not E
, the behavior is undefined.
Constraints
Participates in overload resolution only if T
is const
-qualified.
See also Const and Mutable Spans.
[constexpr]
template <typename It, QSpan<T, E>::if_compatible_iterator = true> QSpan::QSpan(It first, It last)
Constructs a QSpan referencing the data starting at first and having length (last - first).
[first, last)
must be a valid range.
Constraints
Participates in overload resolution only if It
is a compatible iterator.
[constexpr]
template <typename It, QSpan<T, E>::if_compatible_iterator = true> QSpan::QSpan(It first, qsizetype count)
Constructs a QSpan referencing the data starting at first and having length count.
[first, count)
must be a valid range.
Constraints
Participates in overload resolution only if It
is a compatible iterator.
[constexpr]
auto QSpan::back() const
Returns a reference to the last element in the span.
The span must not be empty, otherwise the behavior is undefined.
See also operator[](), front(), size(), empty(), and Const and Mutable Spans.
[constexpr noexcept]
auto QSpan::begin() const
Returns an interator pointing at the beginning of the span.
Because QSpan iterators are just pointers, this is the same as calling data().
See also end(), cbegin(), rbegin(), crbegin(), data(), and Const and Mutable Spans.
[constexpr noexcept]
auto QSpan::cbegin() const
Returns a const_iterator pointing to the beginning of the span.
This will return a read-only iterator even if T
is not const
:
QSpan span = ~~~; *span.begin() = 42; // OK *span.cbegin() = 42; // ERROR: cannot assign through a const_iterator
See also cend(), begin(), crbegin(), rbegin(), data(), and Const and Mutable Spans.
[constexpr noexcept]
auto QSpan::cend() const
Returns a const_iterator pointing to one past the end of the span.
See also cbegin(), end(), crend(), rend(), data(), size(), and Const and Mutable Spans.
[constexpr, since 6.9]
void QSpan::chop(QSpan<T, E>::size_type n)
Same as *this = chopped(
n)
.
This function is only available on variable-sized spans.
This function was introduced in Qt 6.9.
See also chopped().
[constexpr, since 6.9]
auto QSpan::chopped(QSpan<T, E>::size_type n) const
Returns a variable-sized span of size size() - n referencing the first size() - n elements of this span.
Same as first(size() - n)
.
n must be non-negative.
This span must hold at least n elements (E
>= n and size() >= n), otherwise the behavior is undefined.
This function was introduced in Qt 6.9.
See also subspan(), first(QSpan<T,E>::size_type), last(QSpan<T,E>::size_type), and chop().
[constexpr noexcept]
auto QSpan::crbegin() const
Returns a const_reverse_iterator pointing to the beginning of the reversed span.
See also crend(), rbegin(), cbegin(), begin(), and Const and Mutable Spans.
[constexpr noexcept]
auto QSpan::crend() const
Returns a const_reverse_iterator pointing to one past the end of the reversed span.
See also crbegin(), rend(), cend(), end(), and Const and Mutable Spans.
[constexpr noexcept]
auto QSpan::data() const
Returns a pointer to the beginning of the span.
The same as calling begin().
See also begin(), front(), and Const and Mutable Spans.
[constexpr noexcept]
auto QSpan::end() const
Returns an iterator pointing to one past the end of the span.
Because QSpan iterators are just pointers, this it the same as calling data() + size()
.
See also begin(), cend(), rend(), crend(), data(), size(), and Const and Mutable Spans.
[constexpr noexcept(...)]
template <std::size_t Count> auto QSpan::first() const
Returns a fixed-sized span of size Count
referencing the first Count
elements of *this
.
The span must hold at least Count
elements (E
>= Count
and size() >= Count
), otherwise the behavior is undefined.
Note: This function is noexcept when subspan_always_succeeds_v<Count>
is true
.
See also first(QSpan<T,E>::size_type), last(), and subspan().
[constexpr]
auto QSpan::first(QSpan<T, E>::size_type n) const
Returns a variable-sized span of size n referencing the first n elements of *this
.
n must be non-negative.
The span must hold at least n elements (E
>= n and size() >= n), otherwise the behavior is undefined.
See also first(), last(QSpan<T,E>::size_type), subspan(QSpan<T,E>::size_type), subspan(QSpan<T,E>::size_type, QSpan<T,E>::size_type), sliced(), and chopped().
[constexpr]
auto QSpan::front() const
Returns a reference to the first element in the span.
The span must not be empty, otherwise the behavior is undefined.
See also operator[](), back(), size(), empty(), and Const and Mutable Spans.
[constexpr noexcept(...)]
template <std::size_t Count> auto QSpan::last() const
Returns a fixed-sized span of size Count
referencing the last Count
elements of *this
.
The span must hold at least Count
elements (E
>= Count
and size() >= Count
), otherwise the behavior is undefined.
Note: This function is noexcept when subspan_always_succeeds_v<Count>
is true
.
See also last(QSpan<T,E>::size_type), first(), and subspan().
[constexpr]
auto QSpan::last(QSpan<T, E>::size_type n) const
Returns a variable-sized span of size n referencing the last n elements of *this
.
n must be non-negative.
The span must hold at least n elements (E
>= n and size() >= n), otherwise the behavior is undefined.
See also last(), first(QSpan<T,E>::size_type), subspan(QSpan<T,E>::size_type), subspan(QSpan<T,E>::size_type, QSpan<T,E>::size_type), sliced(), and chopped().
[constexpr noexcept]
auto QSpan::rbegin() const
Returns a reverse_iterator pointing to the beginning of the reversed span.
See also rend(), crbegin(), begin(), cbegin(), and Const and Mutable Spans.
[constexpr noexcept]
auto QSpan::rend() const
Returns a reverse_iterator pointing to one past the end of the reversed span.
See also rbegin(), crend(), end(), cend(), and Const and Mutable Spans.
[constexpr noexcept]
auto QSpan::size() const
Returns the size of the span, that is, the number of elements it references.
See also size_bytes(), empty(), and isEmpty().
[constexpr noexcept]
auto QSpan::size_bytes() const
Returns the size of the span in bytes, that is, the number of elements multiplied by sizeof(T)
.
See also size(), empty(), and isEmpty().
[constexpr, since 6.9]
void QSpan::slice(QSpan<T, E>::size_type pos)
Same as *this = sliced(
pos)
.
This function is only available on variable-sized spans.
This function was introduced in Qt 6.9.
See also sliced().
[constexpr, since 6.9]
void QSpan::slice(QSpan<T, E>::size_type pos, QSpan<T, E>::size_type n)
Same as *this = sliced(
pos,
n)
.
This function is only available on variable-sized spans.
This function was introduced in Qt 6.9.
See also sliced().
[constexpr noexcept(...)]
template <std::size_t Offset, std::size_t Count> auto QSpan::subspan() const
Returns a span of size Count
referencing the Count
elements of this span starting at Offset
.
If *this
is a variable-sized span, the return type is a variable-sized span, otherwise it is a fixed-sized span.
This span must hold at least Offset + Count
elements (E
>= Offset + Count
and size() >= Offset + Count
), otherwise the behavior is undefined.
Note: This function is noexcept when subspan_always_succeeds_v<Offset + Count>
is true
.
See also subspan(QSpan<T,E>::size_type, QSpan<T,E>::size_type), subspan(), first(), last(), and Variable-Size and Fixed-Size Spans.
[constexpr noexcept(...)]
template <std::size_t Offset> auto QSpan::subspan() const
Returns a span of size E - Offset
referencing the remainder of this span after dropping the first Offset
elements.
If *this
is a variable-sized span, the return type is a variable-sized span, otherwise it is a fixed-sized span.
This span must hold at least Offset
elements (E
>= Offset
and size() >= Offset
), otherwise the behavior is undefined.
Note: This function is noexcept when subspan_always_succeeds_v<Offset>
is true
.
See also subspan(QSpan<T,E>::size_type), subspan(), first(), last(), and Variable-Size and Fixed-Size Spans.
[constexpr]
QSpan<T, E>::reference QSpan::operator[](QSpan<T, E>::size_type idx) const
Returns a reference to the element at index idx in the span.
The index must be in range, that is, idx >= 0 and idx < size(), otherwise the behavior is undefined.
See also front(), back(), size(), empty(), and Const and Mutable Spans.