Files
cppdraft_translate/cppdraft/indirectcallable.md
2025-10-25 03:02:53 +03:00

66 lines
10 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[indirectcallable]
# 24 Iterators library [[iterators]](./#iterators)
## 24.3 Iterator requirements [[iterator.requirements]](iterator.requirements#indirectcallable)
### 24.3.6 Indirect callable requirements [indirectcallable]
#### [24.3.6.1](#general) General [[indirectcallable.general]](indirectcallable.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L2430)
There are several concepts that group requirements of algorithms that
take callable objects ([[func.def]](func.def "22.10.3Definitions")) as arguments[.](#general-1.sentence-1)
#### [24.3.6.2](#traits) Indirect callable traits [[indirectcallable.traits]](indirectcallable.traits)
[1](#traits-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L2436)
To implement algorithms taking projections,
it is necessary to determine the projected type of an iterator's value type[.](#traits-1.sentence-1)
For the exposition-only alias template *indirect-value-t*,*indirect-value-t*<T> denotes
- [(1.1)](#traits-1.1)
invoke_result_t<Proj&, *indirect-value-t*<I>> if T names projected<I, Proj>, and
- [(1.2)](#traits-1.2)
iter_value_t<T>& otherwise[.](#traits-1.sentence-2)
#### [24.3.6.3](#indirectinvocable) Indirect callables [[indirectcallable.indirectinvocable]](indirectcallable.indirectinvocable)
[1](#indirectinvocable-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L2451)
The indirect callable concepts are used to constrain those algorithms
that accept callable objects ([[func.def]](func.def "22.10.3Definitions")) as arguments[.](#indirectinvocable-1.sentence-1)
namespace std {template<class F, class I>concept [indirectly_unary_invocable](#concept:indirectly_unary_invocable "24.3.6.3Indirect callables[indirectcallable.indirectinvocable]") =[indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2Concept indirectly_­readable[iterator.concept.readable]")<I> &&[copy_constructible](concept.copyconstructible#concept:copy_constructible "18.4.14Concept copy_­constructible[concept.copyconstructible]")<F> &&[invocable](concept.invocable#concept:invocable "18.7.2Concept invocable[concept.invocable]")<F&, *indirect-value-t*<I>> &&[invocable](concept.invocable#concept:invocable "18.7.2Concept invocable[concept.invocable]")<F&, iter_reference_t<I>> &&[common_reference_with](concept.commonref#concept:common_reference_with "18.4.5Concept common_­reference_­with[concept.commonref]")< invoke_result_t<F&, *indirect-value-t*<I>>,
invoke_result_t<F&, iter_reference_t<I>>>; template<class F, class I>concept [indirectly_regular_unary_invocable](#concept:indirectly_regular_unary_invocable "24.3.6.3Indirect callables[indirectcallable.indirectinvocable]") =[indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2Concept indirectly_­readable[iterator.concept.readable]")<I> &&[copy_constructible](concept.copyconstructible#concept:copy_constructible "18.4.14Concept copy_­constructible[concept.copyconstructible]")<F> &&[regular_invocable](concept.regularinvocable#concept:regular_invocable "18.7.3Concept regular_­invocable[concept.regularinvocable]")<F&, *indirect-value-t*<I>> &&[regular_invocable](concept.regularinvocable#concept:regular_invocable "18.7.3Concept regular_­invocable[concept.regularinvocable]")<F&, iter_reference_t<I>> &&[common_reference_with](concept.commonref#concept:common_reference_with "18.4.5Concept common_­reference_­with[concept.commonref]")< invoke_result_t<F&, *indirect-value-t*<I>>,
invoke_result_t<F&, iter_reference_t<I>>>; template<class F, class I>concept [indirect_unary_predicate](#concept:indirect_unary_predicate "24.3.6.3Indirect callables[indirectcallable.indirectinvocable]") =[indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2Concept indirectly_­readable[iterator.concept.readable]")<I> &&[copy_constructible](concept.copyconstructible#concept:copy_constructible "18.4.14Concept copy_­constructible[concept.copyconstructible]")<F> &&[predicate](concept.predicate#concept:predicate "18.7.4Concept predicate[concept.predicate]")<F&, *indirect-value-t*<I>> &&[predicate](concept.predicate#concept:predicate "18.7.4Concept predicate[concept.predicate]")<F&, iter_reference_t<I>>; template<class F, class I1, class I2>concept [indirect_binary_predicate](#concept:indirect_binary_predicate "24.3.6.3Indirect callables[indirectcallable.indirectinvocable]") =[indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2Concept indirectly_­readable[iterator.concept.readable]")<I1> && [indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2Concept indirectly_­readable[iterator.concept.readable]")<I2> &&[copy_constructible](concept.copyconstructible#concept:copy_constructible "18.4.14Concept copy_­constructible[concept.copyconstructible]")<F> &&[predicate](concept.predicate#concept:predicate "18.7.4Concept predicate[concept.predicate]")<F&, *indirect-value-t*<I1>, *indirect-value-t*<I2>> &&[predicate](concept.predicate#concept:predicate "18.7.4Concept predicate[concept.predicate]")<F&, *indirect-value-t*<I1>, iter_reference_t<I2>> &&[predicate](concept.predicate#concept:predicate "18.7.4Concept predicate[concept.predicate]")<F&, iter_reference_t<I1>, *indirect-value-t*<I2>> &&[predicate](concept.predicate#concept:predicate "18.7.4Concept predicate[concept.predicate]")<F&, iter_reference_t<I1>, iter_reference_t<I2>>; template<class F, class I1, class I2 = I1>concept [indirect_equivalence_relation](#concept:indirect_equivalence_relation "24.3.6.3Indirect callables[indirectcallable.indirectinvocable]") =[indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2Concept indirectly_­readable[iterator.concept.readable]")<I1> && [indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2Concept indirectly_­readable[iterator.concept.readable]")<I2> &&[copy_constructible](concept.copyconstructible#concept:copy_constructible "18.4.14Concept copy_­constructible[concept.copyconstructible]")<F> &&[equivalence_relation](concept.equiv#concept:equivalence_relation "18.7.6Concept equivalence_­relation[concept.equiv]")<F&, *indirect-value-t*<I1>, *indirect-value-t*<I2>> &&[equivalence_relation](concept.equiv#concept:equivalence_relation "18.7.6Concept equivalence_­relation[concept.equiv]")<F&, *indirect-value-t*<I1>, iter_reference_t<I2>> &&[equivalence_relation](concept.equiv#concept:equivalence_relation "18.7.6Concept equivalence_­relation[concept.equiv]")<F&, iter_reference_t<I1>, *indirect-value-t*<I2>> &&[equivalence_relation](concept.equiv#concept:equivalence_relation "18.7.6Concept equivalence_­relation[concept.equiv]")<F&, iter_reference_t<I1>, iter_reference_t<I2>>; template<class F, class I1, class I2 = I1>concept [indirect_strict_weak_order](#concept:indirect_strict_weak_order "24.3.6.3Indirect callables[indirectcallable.indirectinvocable]") =[indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2Concept indirectly_­readable[iterator.concept.readable]")<I1> && [indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2Concept indirectly_­readable[iterator.concept.readable]")<I2> &&[copy_constructible](concept.copyconstructible#concept:copy_constructible "18.4.14Concept copy_­constructible[concept.copyconstructible]")<F> &&[strict_weak_order](concept.strictweakorder#concept:strict_weak_order "18.7.7Concept strict_­weak_­order[concept.strictweakorder]")<F&, *indirect-value-t*<I1>, *indirect-value-t*<I2>> &&[strict_weak_order](concept.strictweakorder#concept:strict_weak_order "18.7.7Concept strict_­weak_­order[concept.strictweakorder]")<F&, *indirect-value-t*<I1>, iter_reference_t<I2>> &&[strict_weak_order](concept.strictweakorder#concept:strict_weak_order "18.7.7Concept strict_­weak_­order[concept.strictweakorder]")<F&, iter_reference_t<I1>, *indirect-value-t*<I2>> &&[strict_weak_order](concept.strictweakorder#concept:strict_weak_order "18.7.7Concept strict_­weak_­order[concept.strictweakorder]")<F&, iter_reference_t<I1>, iter_reference_t<I2>>;}
#### [24.3.6.4](#projected) Alias template projected [[projected]](projected)
[1](#projected-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L2515)
Alias template projected is used to constrain algorithms
that accept callable objects and projections ([[defns.projection]](defns.projection "3.44projection"))[.](#projected-1.sentence-1)
It combines an [indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2Concept indirectly_­readable[iterator.concept.readable]") type I and
a callable object type Proj into a new [indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2Concept indirectly_­readable[iterator.concept.readable]") type
whose reference type is the result of applyingProj to the iter_reference_t of I[.](#projected-1.sentence-2)
[🔗](#lib:projected)
namespace std {template<class I, class Proj>struct *projected-impl* { // *exposition only*struct *type* { // *exposition only*using value_type = remove_cvref_t<indirect_result_t<Proj&, I>>; using difference_type = iter_difference_t<I>; // present only if I// models [weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4Concept weakly_­incrementable[iterator.concept.winc]") indirect_result_t<Proj&, I> operator*() const; // *not defined*}; }; template<[indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2Concept indirectly_­readable[iterator.concept.readable]") I, [indirectly_regular_unary_invocable](#concept:indirectly_regular_unary_invocable "24.3.6.3Indirect callables[indirectcallable.indirectinvocable]")<I> Proj>using projected = *projected-impl*<I, Proj>::*type*;}