- Qt 6.10
- Qt Core
- C++ Classes
- ConstReference
- Qt 6.10.2 Reference Documentation

# QVariant::ConstReference Class

template <typename Referred> 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(Referred &&referred)
| ConstReference(const Referred &referred)
QVariant | 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(Referred &&referred)

Creates a QVariant::ConstReference from a referred.

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

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

Creates a QVariant::ConstReference from a referred.

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

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

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

Note: This function is noexcept when `Referred::canNoexceptConvertToQVariant` is `true`.