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

88 lines
7.6 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.

[alg.contains]
# 26 Algorithms library [[algorithms]](./#algorithms)
## 26.6 Non-modifying sequence operations [[alg.nonmodifying]](alg.nonmodifying#alg.contains)
### 26.6.4 Contains [alg.contains]
[🔗](#lib:contains)
`template<[input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9Concept input_­iterator[iterator.concept.input]") I, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7Concept sentinel_­for[iterator.concept.sentinel]")<I> S, class Proj = identity,
class T = projected_value_t<I, Proj>>
requires [indirect_binary_predicate](indirectcallable.indirectinvocable#concept:indirect_binary_predicate "24.3.6.3Indirect callables[indirectcallable.indirectinvocable]")<ranges::equal_to, projected<I, Proj>, const T*>
constexpr bool ranges::contains(I first, S last, const T& value, Proj proj = {});
template<[input_range](range.refinements#concept:input_range "25.4.6Other range refinements[range.refinements]") R, class Proj = identity, class T = projected_value_t<iterator_t<R>, Proj>>
requires [indirect_binary_predicate](indirectcallable.indirectinvocable#concept:indirect_binary_predicate "24.3.6.3Indirect callables[indirectcallable.indirectinvocable]")<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {});
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L4537)
*Returns*: ranges::find(std::move(first), last, value, proj) != last[.](#1.sentence-1)
[🔗](#itemdecl:2)
`template<[execution-policy](algorithms.parallel.defns#concept:execution-policy "26.3.1Preamble[algorithms.parallel.defns]") Ep, [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13Concept random_­access_­iterator[iterator.concept.random.access]") I, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8Concept sized_­sentinel_­for[iterator.concept.sizedsentinel]")<I> S,
class Proj = identity, class T = projected_value_t<I, Proj>>
requires [indirect_binary_predicate](indirectcallable.indirectinvocable#concept:indirect_binary_predicate "24.3.6.3Indirect callables[indirectcallable.indirectinvocable]")<ranges::equal_to, projected<I, Proj>, const T*>
bool ranges::contains(Ep&& exec, I first, S last, const T& value, Proj proj = {});
template<[execution-policy](algorithms.parallel.defns#concept:execution-policy "26.3.1Preamble[algorithms.parallel.defns]") Ep, [sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6Other range refinements[range.refinements]") R, class Proj = identity,
class T = projected_value_t<iterator_t<R>, Proj>>
requires
[indirect_binary_predicate](indirectcallable.indirectinvocable#concept:indirect_binary_predicate "24.3.6.3Indirect callables[indirectcallable.indirectinvocable]")<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
bool ranges::contains(Ep&& exec, R&& r, const T& value, Proj proj = {});
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L4555)
*Returns*: ranges::find(std::forward<Ep>(exec), first, last, value, proj) != last[.](#2.sentence-1)
[🔗](#lib:contains_subrange)
`template<[forward_iterator](iterator.concept.forward#concept:forward_iterator "24.3.4.11Concept forward_­iterator[iterator.concept.forward]") I1, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7Concept sentinel_­for[iterator.concept.sentinel]")<I1> S1,
[forward_iterator](iterator.concept.forward#concept:forward_iterator "24.3.4.11Concept forward_­iterator[iterator.concept.forward]") I2, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7Concept sentinel_­for[iterator.concept.sentinel]")<I2> S2,
class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
requires [indirectly_comparable](alg.req.ind.cmp#concept:indirectly_comparable "24.3.7.5Concept indirectly_­comparable[alg.req.ind.cmp]")<I1, I2, Pred, Proj1, Proj2>
constexpr bool ranges::contains_subrange(I1 first1, S1 last1, I2 first2, S2 last2,
Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
template<[forward_range](range.refinements#concept:forward_range "25.4.6Other range refinements[range.refinements]") R1, [forward_range](range.refinements#concept:forward_range "25.4.6Other range refinements[range.refinements]") R2,
class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
requires [indirectly_comparable](alg.req.ind.cmp#concept:indirectly_comparable "24.3.7.5Concept indirectly_­comparable[alg.req.ind.cmp]")<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
constexpr bool ranges::contains_subrange(R1&& r1, R2&& r2, Pred pred = {},
Proj1 proj1 = {}, Proj2 proj2 = {});
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L4576)
*Returns*: first2 == last2 || !ranges::search(first1, last1, first2, last2,
pred, proj1, proj2).empty()
[🔗](#itemdecl:4)
`template<[execution-policy](algorithms.parallel.defns#concept:execution-policy "26.3.1Preamble[algorithms.parallel.defns]") Ep, [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13Concept random_­access_­iterator[iterator.concept.random.access]") I1, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8Concept sized_­sentinel_­for[iterator.concept.sizedsentinel]")<I1> S1,
[random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13Concept random_­access_­iterator[iterator.concept.random.access]") I2, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8Concept sized_­sentinel_­for[iterator.concept.sizedsentinel]")<I2> S2,
class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
requires [indirectly_comparable](alg.req.ind.cmp#concept:indirectly_comparable "24.3.7.5Concept indirectly_­comparable[alg.req.ind.cmp]")<I1, I2, Pred, Proj1, Proj2>
bool ranges::contains_subrange(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2,
Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
template<[execution-policy](algorithms.parallel.defns#concept:execution-policy "26.3.1Preamble[algorithms.parallel.defns]") Ep, [sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6Other range refinements[range.refinements]") R1, [sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6Other range refinements[range.refinements]") R2,
class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
requires [indirectly_comparable](alg.req.ind.cmp#concept:indirectly_comparable "24.3.7.5Concept indirectly_­comparable[alg.req.ind.cmp]")<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
bool ranges::contains_subrange(Ep&& exec, R1&& r1, R2&& r2, Pred pred = {},
Proj1 proj1 = {}, Proj2 proj2 = {});
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L4599)
*Returns*: first2 == last2 || !ranges::search(std::forward<Ep>(exec), first1, last1,
first2, last2, pred, proj1, proj2).empty()