QVariant::ConstReference Class | Qt Core | Qt 6.11.0
Description: The QVariant::ConstReference acts as a const reference to a QVariant.

- Qt 6.11
- Qt Core
- C++ Classes
- ConstReference
- Qt 6.11.0 Reference Documentation

# QVariant::ConstReference Class

template <typename Indirect> class QVariant::ConstReference

The QVariant::ConstReference acts as a const reference to a QVariant. More...

This class was introduced in Qt 6.11.

- List of all members, including inherited members

## Public Functions

| ConstReference(Indirect &&referred)
| ConstReference(QVariant::Reference<Indirect> &&nonConst)
| ConstReference(const Indirect &referred)
| ConstReference(const QVariant::Reference<Indirect> &nonConst)
| operator QVariant() const

## Detailed Description

As the generic iterators don't actually instantiate a QVariant on each step, they cannot return a reference to one from operator*(). QVariant::ConstReference provides the same functionality as an actual reference to a QVariant would, but is backed a referred-to value given as template parameter. The template is implemented for QMetaSequence::ConstIterator, QMetaSequence::Iterator, QMetaAssociation::ConstIterator, and QMetaAssociation::Iterator.

## Member Function Documentation

### `[explicit noexcept(...)]` ConstReference::ConstReference(Indirect &&referred)

Creates a QVariant::ConstReference from a referred.

Note: This function is noexcept when `std::is_nothrow_move_constructible_v<Indirect>` is `true`.

### `[default]` ConstReference::ConstReference(QVariant::Reference<Indirect> &&nonConst)

Creates a QVariant::ConstReference from a nonConst Reference.

### `[explicit noexcept(...)]` ConstReference::ConstReference(const Indirect &referred)

Creates a QVariant::ConstReference from a referred.

Note: This function is noexcept when `std::is_nothrow_copy_constructible_v<Indirect>` is `true`.

### `[noexcept(...)]` ConstReference::ConstReference(const QVariant::Reference<Indirect> &nonConst)

Creates a QVariant::ConstReference from a nonConst Reference.

Note: This function is noexcept when `std::is_nothrow_copy_constructible_v<Indirect>` is `true`.

### `[noexcept(...)]` ConstReference::operator QVariant() const

Dereferences the reference to a QVariant. This method needs to be specialized for each Indirect type. It is pre-defined for QMetaSequence::ConstIterator, QMetaSequence::Iterator, QMetaAssociation::ConstIterator, and QMetaAssociation::Iterator.

Note: This function is noexcept when `Indirect::CanNoexceptConvertToQVariant` is `true`.