[alg.req]

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

## 24.3 Iterator requirements [[iterator.requirements]](iterator.requirements#alg.req)

### 24.3.7 Common algorithm requirements [alg.req]

#### [24.3.7.1](#general) General [[alg.req.general]](alg.req.general)

[1](#general-1)

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

There are several additional iterator concepts that are commonly applied
to families of algorithms[.](#general-1.sentence-1)

These group together iterator requirements
of algorithm families[.](#general-1.sentence-2)

There are three relational concepts that specify
how element values are transferred between[indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2 Concept indirectly_­readable [iterator.concept.readable]") and [indirectly_writable](iterator.concept.writable#concept:indirectly_writable "24.3.4.3 Concept indirectly_­writable [iterator.concept.writable]") types:[indirectly_movable](#concept:indirectly_movable "24.3.7.2 Concept indirectly_­movable [alg.req.ind.move]"),[indirectly_copyable](#concept:indirectly_copyable "24.3.7.3 Concept indirectly_­copyable [alg.req.ind.copy]"), and[indirectly_swappable](#concept:indirectly_swappable "24.3.7.4 Concept indirectly_­swappable [alg.req.ind.swap]")[.](#general-1.sentence-3)

There are three relational concepts for rearrangements:[permutable](#concept:permutable "24.3.7.6 Concept permutable [alg.req.permutable]"),[mergeable](#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]"), and[sortable](#concept:sortable "24.3.7.8 Concept sortable [alg.req.sortable]")[.](#general-1.sentence-4)

There is one relational concept for comparing values from different sequences:[indirectly_comparable](#concept:indirectly_comparable "24.3.7.5 Concept indirectly_­comparable [alg.req.ind.cmp]")[.](#general-1.sentence-5)

[2](#general-2)

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

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

The ranges​::​less function object type
used in the concepts below imposes constraints on the concepts' arguments
in addition to those that appear in the concepts' bodies ([[range.cmp]](range.cmp "22.10.9 Concept-constrained comparisons"))[.](#general-2.sentence-1)

â *end note*]

#### [24.3.7.2](#ind.move) Concept indirectly_movable [[alg.req.ind.move]](alg.req.ind.move)

[1](#ind.move-1)

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

The [indirectly_movable](#concept:indirectly_movable "24.3.7.2 Concept indirectly_­movable [alg.req.ind.move]") concept specifies the relationship between
an [indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2 Concept indirectly_­readable [iterator.concept.readable]") type and an [indirectly_writable](iterator.concept.writable#concept:indirectly_writable "24.3.4.3 Concept indirectly_­writable [iterator.concept.writable]") type
between which values may be moved[.](#ind.move-1.sentence-1)

template<class In, class Out>concept [indirectly_movable](#concept:indirectly_movable "24.3.7.2 Concept indirectly_­movable [alg.req.ind.move]") =[indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2 Concept indirectly_­readable [iterator.concept.readable]")<In> &&[indirectly_writable](iterator.concept.writable#concept:indirectly_writable "24.3.4.3 Concept indirectly_­writable [iterator.concept.writable]")<Out, iter_rvalue_reference_t<In>>;

[2](#ind.move-2)

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

The [indirectly_movable_storable](#concept:indirectly_movable_storable "24.3.7.2 Concept indirectly_­movable [alg.req.ind.move]") concept augments[indirectly_movable](#concept:indirectly_movable "24.3.7.2 Concept indirectly_­movable [alg.req.ind.move]") with additional requirements enabling
the transfer to be performed through an intermediate object of the[indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2 Concept indirectly_­readable [iterator.concept.readable]") type's value type[.](#ind.move-2.sentence-1)

template<class In, class Out>concept [indirectly_movable_storable](#concept:indirectly_movable_storable "24.3.7.2 Concept indirectly_­movable [alg.req.ind.move]") =[indirectly_movable](#concept:indirectly_movable "24.3.7.2 Concept indirectly_­movable [alg.req.ind.move]")<In, Out> &&[indirectly_writable](iterator.concept.writable#concept:indirectly_writable "24.3.4.3 Concept indirectly_­writable [iterator.concept.writable]")<Out, iter_value_t<In>> &&[movable](concepts.object#concept:movable "18.6 Object concepts [concepts.object]")<iter_value_t<In>> &&[constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_­from [concept.constructible]")<iter_value_t<In>, iter_rvalue_reference_t<In>> &&[assignable_from](concept.assignable#concept:assignable_from "18.4.8 Concept assignable_­from [concept.assignable]")<iter_value_t<In>&, iter_rvalue_reference_t<In>>;

[3](#ind.move-3)

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

Let i be a dereferenceable value of type In[.](#ind.move-3.sentence-1)

In and Out model [indirectly_movable_storable](#concept:indirectly_movable_storable "24.3.7.2 Concept indirectly_­movable [alg.req.ind.move]")<In, Out> only if after the initialization of the object obj initer_value_t<In> obj(ranges::iter_move(i));obj is equal to the value previously denoted by *i[.](#ind.move-3.sentence-2)

Ifiter_rvalue_reference_t<In> is an rvalue reference type,
the resulting state of the value denoted by *i is
valid but unspecified ([[lib.types.movedfrom]](lib.types.movedfrom "16.4.6.17 Moved-from state of library types"))[.](#ind.move-3.sentence-3)

#### [24.3.7.3](#ind.copy) Concept indirectly_copyable [[alg.req.ind.copy]](alg.req.ind.copy)

[1](#ind.copy-1)

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

The [indirectly_copyable](#concept:indirectly_copyable "24.3.7.3 Concept indirectly_­copyable [alg.req.ind.copy]") concept specifies the relationship between
an [indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2 Concept indirectly_­readable [iterator.concept.readable]") type and an [indirectly_writable](iterator.concept.writable#concept:indirectly_writable "24.3.4.3 Concept indirectly_­writable [iterator.concept.writable]") type
between which values may be copied[.](#ind.copy-1.sentence-1)

template<class In, class Out>concept [indirectly_copyable](#concept:indirectly_copyable "24.3.7.3 Concept indirectly_­copyable [alg.req.ind.copy]") =[indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2 Concept indirectly_­readable [iterator.concept.readable]")<In> &&[indirectly_writable](iterator.concept.writable#concept:indirectly_writable "24.3.4.3 Concept indirectly_­writable [iterator.concept.writable]")<Out, iter_reference_t<In>>;

[2](#ind.copy-2)

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

The [indirectly_copyable_storable](#concept:indirectly_copyable_storable "24.3.7.3 Concept indirectly_­copyable [alg.req.ind.copy]") concept augments[indirectly_copyable](#concept:indirectly_copyable "24.3.7.3 Concept indirectly_­copyable [alg.req.ind.copy]") with additional requirements enabling
the transfer to be performed through an intermediate object of the[indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2 Concept indirectly_­readable [iterator.concept.readable]") type's value type[.](#ind.copy-2.sentence-1)

It also requires the capability
to make copies of values[.](#ind.copy-2.sentence-2)

template<class In, class Out>concept [indirectly_copyable_storable](#concept:indirectly_copyable_storable "24.3.7.3 Concept indirectly_­copyable [alg.req.ind.copy]") =[indirectly_copyable](#concept:indirectly_copyable "24.3.7.3 Concept indirectly_­copyable [alg.req.ind.copy]")<In, Out> &&[indirectly_writable](iterator.concept.writable#concept:indirectly_writable "24.3.4.3 Concept indirectly_­writable [iterator.concept.writable]")<Out, iter_value_t<In>&> &&[indirectly_writable](iterator.concept.writable#concept:indirectly_writable "24.3.4.3 Concept indirectly_­writable [iterator.concept.writable]")<Out, const iter_value_t<In>&> &&[indirectly_writable](iterator.concept.writable#concept:indirectly_writable "24.3.4.3 Concept indirectly_­writable [iterator.concept.writable]")<Out, iter_value_t<In>&&> &&[indirectly_writable](iterator.concept.writable#concept:indirectly_writable "24.3.4.3 Concept indirectly_­writable [iterator.concept.writable]")<Out, const iter_value_t<In>&&> &&[copyable](concepts.object#concept:copyable "18.6 Object concepts [concepts.object]")<iter_value_t<In>> &&[constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_­from [concept.constructible]")<iter_value_t<In>, iter_reference_t<In>> &&[assignable_from](concept.assignable#concept:assignable_from "18.4.8 Concept assignable_­from [concept.assignable]")<iter_value_t<In>&, iter_reference_t<In>>;

[3](#ind.copy-3)

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

Let i be a dereferenceable value of type In[.](#ind.copy-3.sentence-1)

In and Out model [indirectly_copyable_storable](#concept:indirectly_copyable_storable "24.3.7.3 Concept indirectly_­copyable [alg.req.ind.copy]")<In, Out> only if after the initialization of the object obj initer_value_t<In> obj(*i);obj is equal to the value previously denoted by *i[.](#ind.copy-3.sentence-2)

Ifiter_reference_t<In> is an rvalue reference type, the resulting state
of the value denoted by *i is
valid but unspecified ([[lib.types.movedfrom]](lib.types.movedfrom "16.4.6.17 Moved-from state of library types"))[.](#ind.copy-3.sentence-3)

#### [24.3.7.4](#ind.swap) Concept indirectly_swappable [[alg.req.ind.swap]](alg.req.ind.swap)

[1](#ind.swap-1)

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

The [indirectly_swappable](#concept:indirectly_swappable "24.3.7.4 Concept indirectly_­swappable [alg.req.ind.swap]") concept specifies a swappable relationship
between the values referenced by two [indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2 Concept indirectly_­readable [iterator.concept.readable]") types[.](#ind.swap-1.sentence-1)

template<class I1, class I2 = I1>concept [indirectly_swappable](#concept:indirectly_swappable "24.3.7.4 Concept indirectly_­swappable [alg.req.ind.swap]") =[indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2 Concept indirectly_­readable [iterator.concept.readable]")<I1> && [indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2 Concept indirectly_­readable [iterator.concept.readable]")<I2> &&requires(const I1 i1, const I2 i2) { ranges::iter_swap(i1, i1);
 ranges::iter_swap(i2, i2);
 ranges::iter_swap(i1, i2);
 ranges::iter_swap(i2, i1); };

#### [24.3.7.5](#ind.cmp) Concept indirectly_comparable [[alg.req.ind.cmp]](alg.req.ind.cmp)

[1](#ind.cmp-1)

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

The [indirectly_comparable](#concept:indirectly_comparable "24.3.7.5 Concept indirectly_­comparable [alg.req.ind.cmp]") concept specifies
the common requirements of algorithms that
compare values from two different sequences[.](#ind.cmp-1.sentence-1)

template<class I1, class I2, class R, class P1 = identity, class P2 = identity>concept [indirectly_comparable](#concept:indirectly_comparable "24.3.7.5 Concept indirectly_­comparable [alg.req.ind.cmp]") =[indirect_binary_predicate](indirectcallable.indirectinvocable#concept:indirect_binary_predicate "24.3.6.3 Indirect callables [indirectcallable.indirectinvocable]")<R, projected<I1, P1>, projected<I2, P2>>;

#### [24.3.7.6](#permutable) Concept permutable [[alg.req.permutable]](alg.req.permutable)

[1](#permutable-1)

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

The [permutable](#concept:permutable "24.3.7.6 Concept permutable [alg.req.permutable]") concept specifies the common requirements
of algorithms that reorder elements in place by moving or swapping them[.](#permutable-1.sentence-1)

template<class I>concept [permutable](#concept:permutable "24.3.7.6 Concept permutable [alg.req.permutable]") =[forward_iterator](iterator.concept.forward#concept:forward_iterator "24.3.4.11 Concept forward_­iterator [iterator.concept.forward]")<I> &&[indirectly_movable_storable](#concept:indirectly_movable_storable "24.3.7.2 Concept indirectly_­movable [alg.req.ind.move]")<I, I> &&[indirectly_swappable](#concept:indirectly_swappable "24.3.7.4 Concept indirectly_­swappable [alg.req.ind.swap]")<I, I>;

#### [24.3.7.7](#mergeable) Concept mergeable [[alg.req.mergeable]](alg.req.mergeable)

[1](#mergeable-1)

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

The [mergeable](#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]") concept specifies the requirements of algorithms
that merge sorted sequences into an output sequence by copying elements[.](#mergeable-1.sentence-1)

template<class I1, class I2, class Out, class R = ranges::less, class P1 = identity, class P2 = identity>concept [mergeable](#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]") =[input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_­iterator [iterator.concept.input]")<I1> &&[input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_­iterator [iterator.concept.input]")<I2> &&[weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_­incrementable [iterator.concept.winc]")<Out> &&[indirectly_copyable](#concept:indirectly_copyable "24.3.7.3 Concept indirectly_­copyable [alg.req.ind.copy]")<I1, Out> &&[indirectly_copyable](#concept:indirectly_copyable "24.3.7.3 Concept indirectly_­copyable [alg.req.ind.copy]")<I2, Out> &&[indirect_strict_weak_order](indirectcallable.indirectinvocable#concept:indirect_strict_weak_order "24.3.6.3 Indirect callables [indirectcallable.indirectinvocable]")<R, projected<I1, P1>, projected<I2, P2>>;

#### [24.3.7.8](#sortable) Concept sortable [[alg.req.sortable]](alg.req.sortable)

[1](#sortable-1)

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

The [sortable](#concept:sortable "24.3.7.8 Concept sortable [alg.req.sortable]") concept specifies the common requirements of
algorithms that permute sequences into ordered sequences (e.g., sort)[.](#sortable-1.sentence-1)

template<class I, class R = ranges::less, class P = identity>concept [sortable](#concept:sortable "24.3.7.8 Concept sortable [alg.req.sortable]") =[permutable](#concept:permutable "24.3.7.6 Concept permutable [alg.req.permutable]")<I> &&[indirect_strict_weak_order](indirectcallable.indirectinvocable#concept:indirect_strict_weak_order "24.3.6.3 Indirect callables [indirectcallable.indirectinvocable]")<R, projected<I, P>>;
