QVariant::Reference Class | Qt Core | Qt 6.11.1
Description: The QVariant::Reference acts as a non-const reference to a QVariant.

- Qt 6.11
- Qt Core
- C++ Classes
- Reference
- Qt 6.11.1 Reference Documentation

# QVariant::Reference Class

template <typename Indirect> class QVariant::Reference

The QVariant::Reference acts as a non-const reference to a QVariant. More...

This class was introduced in Qt 6.11.

- List of all members, including inherited members

## Public Functions

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

## 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::Reference 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::Iterator and QMetaAssociation::Iterator.

## Member Function Documentation

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

Creates a QVariant::Reference from a referred.

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

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

Creates a QVariant::Reference from a referred.

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

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

Dereferences the reference to a QVariant. By default this instantiates a temporary QVariant::ConstReference and calls dereferences that. In cases where instantiating a temporary ConstReference is expensive, this method should be specialized.

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

### `[noexcept(...)]` QVariant::Reference<Indirect> &Reference::operator=(QVariant::ConstReference<Indirect> &&value)

Assigns a new value to the value referred to by this QVariant::Reference.

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

### `[noexcept(...)]` QVariant::Reference<Indirect> &Reference::operator=(QVariant::Reference<Indirect> &&value)

Assigns a new value to the value referred to by this QVariant::Reference.

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

### `[noexcept(...)]` QVariant::Reference<Indirect> &Reference::operator=(const QVariant &value)

Assigns a new value to the value referred to by this QVariant::Reference. This method needs to be specialized for each Indirect type. It is pre-defined for QMetaSequence::Iterator and QMetaAssociation::Iterator.

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

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

Assigns a new value to the value referred to by this QVariant::Reference.

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

### `[noexcept(...)]` QVariant::Reference<Indirect> &Reference::operator=(const QVariant::Reference<Indirect> &value)

Assigns a new value to the value referred to by this QVariant::Reference.

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