ConstIterator Class | Qt Core 6.4.3

- Qt 6.4
- Qt Core
- C++ Classes
- ConstIterator
- Qt 6.4.3 Reference Documentation

# ConstIterator Class

class QCborArray::ConstIterator

The QCborArray::ConstIterator class provides an STL-style const iterator for QCborArray. More...

This class was introduced in Qt 5.12.

- List of all members, including inherited members

## Public Types

| iterator_category

## Public Functions

| ConstIterator(const ConstIterator &other)
| ConstIterator()
ConstIterator & | operator=(const ConstIterator &other)
bool | operator!=(const Iterator &o) const
bool | operator!=(const ConstIterator &o) const
QCborValueConstRef | operator*() const
ConstIterator | operator+(qsizetype j) const
ConstIterator & | operator++()
ConstIterator | operator++(int)
ConstIterator & | operator+=(qsizetype j)
ConstIterator | operator-(qsizetype j) const
qsizetype | operator-(ConstIterator other) const
ConstIterator & | operator--()
ConstIterator | operator--(int)
ConstIterator & | operator-=(qsizetype j)
const QCborValueConstRef * | operator->() const
bool | operator<(const Iterator &other) const
bool | operator<(const ConstIterator &other) const
bool | operator<=(const Iterator &other) const
bool | operator<=(const ConstIterator &other) const
bool | operator==(const Iterator &other) const
bool | operator==(const ConstIterator &other) const
bool | operator>(const Iterator &other) const
bool | operator>(const ConstIterator &other) const
bool | operator>=(const Iterator &other) const
bool | operator>=(const ConstIterator &other) const
QCborValueConstRef | operator[](qsizetype j) const

## Detailed Description

QCborArray::ConstIterator allows you to iterate over a QCborArray. If you want to modify the QCborArray as you iterate over it, use QCborArray::Iterator instead. It is generally good practice to use QCborArray::ConstIterator, even on a non-const QCborArray, when you don't need to change the QCborArray through the iterator. Const iterators are slightly faster and improves code readability.

Iterators are initialized by using a QCborArray function like QCborArray::begin() or QCborArray::end(). Iteration is only possible after that.

Most QCborArray functions accept an integer index rather than an iterator. For that reason, iterators are rarely useful in connection with QCborArray. One place where STL-style iterators do make sense is as arguments to generic algorithms.

Multiple iterators can be used on the same array. However, be aware that any non-const function call performed on the QCborArray will render all existing iterators undefined.

See also QCborArray::Iterator.

## Member Type Documentation

### ConstIterator::iterator_category

A synonym for std::random_access_iterator_tag indicating this iterator is a random access iterator.

## Member Function Documentation

### bool ConstIterator::operator>=(const ConstIterator &other) const

### bool ConstIterator::operator>=(const Iterator &other) const

Returns `true` if the entry in the array pointed to by this iterator occurs after or is the same entry as is pointed to by the other iterator.

### bool ConstIterator::operator>(const ConstIterator &other) const

### bool ConstIterator::operator>(const Iterator &other) const

Returns `true` if the entry in the array pointed to by this iterator occurs after the entry pointed to by the other iterator.

### bool ConstIterator::operator<=(const ConstIterator &other) const

### bool ConstIterator::operator<=(const Iterator &other) const

Returns `true` if the entry in the array pointed to by this iterator occurs before or is the same entry as is pointed to by the other iterator.

### bool ConstIterator::operator<(const ConstIterator &other) const

### bool ConstIterator::operator<(const Iterator &other) const

Returns `true` if the entry in the array pointed to by this iterator occurs before the entry pointed to by the other iterator.

### bool ConstIterator::operator!=(const ConstIterator &o) const

### bool ConstIterator::operator!=(const Iterator &o) const

Returns `true` if o points to a different entry in the array than this iterator; otherwise returns `false`.

See also operator==().

### bool ConstIterator::operator==(const ConstIterator &other) const

### bool ConstIterator::operator==(const Iterator &other) const

Returns `true` if other points to the same entry in the array as this iterator; otherwise returns `false`.

See also operator!=().

### ConstIterator::ConstIterator(const ConstIterator &other)

Constructs a copy of other.

### ConstIterator::ConstIterator()

Constructs an uninitialized iterator.

Functions like operator*() and operator++() should not be called on an uninitialized iterator. Use operator=() to assign a value to it before using it.

See also QCborArray::constBegin() and QCborArray::constEnd().

### ConstIterator &ConstIterator::operator=(const ConstIterator &other)

Makes this iterator a copy of other and returns a reference to this iterator.

### QCborValueConstRef ConstIterator::operator*() const

Returns the current item.

### ConstIterator ConstIterator::operator+(qsizetype j) const

Returns an iterator to the item at a position j steps forward from this iterator. If j is negative, the iterator goes backward.

See also operator-() and operator+=().

### ConstIterator &ConstIterator::operator++()

The prefix ++ operator, `++it`, advances the iterator to the next item in the array and returns this iterator.

Calling this function on QCborArray::end() leads to undefined results.

See also operator--().

### ConstIterator ConstIterator::operator++(int)

This is an overloaded function.

The postfix ++ operator, `it++`, advances the iterator to the next item in the array and returns an iterator to the previously current item.

### ConstIterator &ConstIterator::operator+=(qsizetype j)

Advances the iterator by j positions. If j is negative, the iterator goes backward. Returns a reference to this iterator.

See also operator-=() and operator+().

### ConstIterator ConstIterator::operator-(qsizetype j) const

Returns an iterator to the item at a position j steps backward from this iterator. If j is negative, the iterator goes forward.

See also operator+() and operator-=().

### qsizetype ConstIterator::operator-(ConstIterator other) const

Returns the offset of this iterator relative to other.

### ConstIterator &ConstIterator::operator--()

The prefix -- operator, `--it`, makes the preceding item current and returns this iterator.

Calling this function on QCborArray::begin() leads to undefined results.

See also operator++().

### ConstIterator ConstIterator::operator--(int)

This is an overloaded function.

The postfix -- operator, `it--`, makes the preceding item current and returns an iterator to the previously current item.

### ConstIterator &ConstIterator::operator-=(qsizetype j)

Makes the iterator go back by j positions. If j is negative, the iterator goes forward. Returns a reference to this iterator.

See also operator+=() and operator-().

### const QCborValueConstRef *ConstIterator::operator->() const

Returns a pointer to the current item.

### QCborValueConstRef ConstIterator::operator[](qsizetype j) const

Returns the item at a position j steps forward from the item pointed to by this iterator.

This function is provided to make QCborArray iterators behave like C++ pointers.

See also operator+().