[alg.req] (original) (raw)

23 Iterators library [iterators]

23.3 Iterator requirements [iterator.requirements]

23.3.7 Common algorithm requirements [alg.req]

23.3.7.1 General [alg.req.general]

There are several additional iterator concepts that are commonly applied to families of algorithms.

These group together iterator requirements of algorithm families.

There are three relational concepts for rearrangements:permutable,mergeable, andsortable.

There is one relational concept for comparing values from different sequences:indirectly_­comparable.

[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]).

— _end note_]

23.3.7.2 Concept indirectly_­movable [alg.req.ind.move]

Let i be a dereferenceable value of type In.

In and Out model indirectly_­movable_­storable<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.

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]).

23.3.7.3 Concept indirectly_­copyable [alg.req.ind.copy]

The indirectly_­copyable_­storable concept augmentsindirectly_­copyable with additional requirements enabling the transfer to be performed through an intermediate object of theindirectly_­readable type's value type.

It also requires the capability to make copies of values.

Let i be a dereferenceable value of type In.

In and Out model indirectly_­copyable_­storable<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.

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]).

23.3.7.5 Concept indirectly_­comparable [alg.req.ind.cmp]

The indirectly_­comparable concept specifies the common requirements of algorithms that compare values from two different sequences.

template<class I1, class I2, class R, class P1 = identity,class P2 = identity> concept indirectly_­comparable = indirect_­binary_­predicate<R, projected<I1, P1>, projected<I2, P2>>;

23.3.7.6 Concept permutable [alg.req.permutable]

The permutable concept specifies the common requirements of algorithms that reorder elements in place by moving or swapping them.

23.3.7.7 Concept mergeable [alg.req.mergeable]

The mergeable concept specifies the requirements of algorithms that merge sorted sequences into an output sequence by copying elements.

template<class I1, class I2, class Out, class R = ranges::less,class P1 = identity, class P2 = identity> concept mergeable = input_­iterator<I1> && input_­iterator<I2> && weakly_­incrementable<Out> && indirectly_­copyable<I1, Out> && indirectly_­copyable<I2, Out> && indirect_­strict_­weak_­order<R, projected<I1, P1>, projected<I2, P2>>;

23.3.7.8 Concept sortable [alg.req.sortable]

The sortable concept specifies the common requirements of algorithms that permute sequences into ordered sequences (e.g., sort).

template<class I, class R = ranges::less, class P = identity> concept sortable = permutable<I> && indirect_­strict_­weak_­order<R, projected<I, P>>;