[iterator.concept.writable]

# 24 Iterators library [[iterators]](./#iterators)

## 24.3 Iterator requirements [[iterator.requirements]](iterator.requirements#iterator.concept.writable)

### 24.3.4 Iterator concepts [[iterator.concepts]](iterator.concepts#iterator.concept.writable)

#### 24.3.4.3 Concept indirectly_writable [iterator.concept.writable]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L1331)

The [indirectly_writable](#concept:indirectly_writable "24.3.4.3 Concept indirectly_­writable [iterator.concept.writable]") concept specifies the requirements
for writing a value into an iterator's referenced object[.](#1.sentence-1)

template<class Out, class T>concept [indirectly_writable](#concept:indirectly_writable "24.3.4.3 Concept indirectly_­writable [iterator.concept.writable]") =requires(Out&& o, T&& t) {*o = std::forward<T>(t); // not required to be equality-preserving*std::forward<Out>(o) = std::forward<T>(t); // not required to be equality-preservingconst_cast<const iter_reference_t<Out>&&>(*o) = std::forward<T>(t); // not required to be equality-preservingconst_cast<const iter_reference_t<Out>&&>(*std::forward<Out>(o)) = std::forward<T>(t); // not required to be equality-preserving};

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L1348)

Let E be an expression such that decltype((E)) is T,
and let o be a dereferenceable object of type Out[.](#2.sentence-1)

Out and T model [indirectly_writable](#concept:indirectly_writable "24.3.4.3 Concept indirectly_­writable [iterator.concept.writable]")<Out, T> only if:

- [(2.1)](#2.1)

If Out and T model [indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2 Concept indirectly_­readable [iterator.concept.readable]")<Out> && [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<iter_value_t<Out>, decay_t<T>>,
 then *o after any above assignment is equal to
 the value of E before the assignment[.](#2.sentence-2)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L1359)

After evaluating any above assignment expression, o is not required to be dereferenceable[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L1362)

If E is an xvalue ([[basic.lval]](basic.lval "7.2.1 Value category")), the resulting
state of the object it denotes is valid but unspecified ([[lib.types.movedfrom]](lib.types.movedfrom "16.4.6.17 Moved-from state of library types"))[.](#4.sentence-1)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L1366)

[*Note [1](#note-1)*:

The only valid use of an operator* is on the left side of the assignment statement[.](#5.sentence-1)

Assignment through the same value of the indirectly writable type happens only once[.](#5.sentence-2)

â *end note*]

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L1372)

[*Note [2](#note-2)*:

[indirectly_writable](#concept:indirectly_writable "24.3.4.3 Concept indirectly_­writable [iterator.concept.writable]") has the awkward const_cast expressions to reject
iterators with prvalue non-proxy reference types that permit rvalue
assignment but do not also permit const rvalue assignment[.](#6.sentence-1)

Consequently, an iterator type I that returns std​::​string by value does not model [indirectly_writable](#concept:indirectly_writable "24.3.4.3 Concept indirectly_­writable [iterator.concept.writable]")<I, std​::​string>[.](#6.sentence-2)

â *end note*]
