std::experimental::ranges::all_of,std::experimental::ranges::any_of,std::experimental::ranges::none_of (3) - Linux Manuals
std::experimental::ranges::all_of,std::experimental::ranges::any_of,std::experimental::ranges::none_of: std::experimental::ranges::all_of,std::experimental::ranges::any_of,std::experimental::ranges::none_of
NAME
std::experimental::ranges::all_of,std::experimental::ranges::any_of,std::experimental::ranges::none_of - std::experimental::ranges::all_of,std::experimental::ranges::any_of,std::experimental::ranges::none_of
Synopsis
Defined in header <experimental/ranges/algorithm>
template< InputIterator I, Sentinel<I> S, class Proj = ranges::identity,
IndirectUnaryPredicate<projected<I, Proj>> Pred > (1) (ranges TS)
bool all_of( I first, S last, Pred pred, Proj proj = Proj{} );
template< InputRange R, class Proj = ranges::identity,
IndirectUnaryPredicate<projected<ranges::iterator_t<R>, Proj>> Pred > (2) (ranges TS)
bool all_of( R&& r, Pred pred, Proj proj = Proj{} );
template< InputIterator I, Sentinel<I> S, class Proj = ranges::identity,
IndirectUnaryPredicate<projected<I, Proj>> Pred > (3) (ranges TS)
bool any_of( I first, S last, Pred pred, Proj proj = Proj{} );
template< InputRange R, class Proj = ranges::identity,
IndirectUnaryPredicate<projected<ranges::iterator_t<R>, Proj>> Pred > (4) (ranges TS)
bool any_of( R&& r, Pred pred, Proj proj = Proj{} );
template< InputIterator I, Sentinel<I> S, class Proj = identity,
IndirectUnaryPredicate<projected<I, Proj>> Pred > (5) (ranges TS)
bool none_of( I first, S last, Pred pred, Proj proj = Proj{} );
template< InputRange R, class Proj = ranges::identity,
IndirectUnaryPredicate<projected<ranges::iterator_t<R>, Proj>> Pred > (6) (ranges TS)
bool none_of( R&& r, Pred pred, Proj proj = Proj{} );
1) Checks if unary predicate pred returns true for all elements in the range [first, last).
3) Checks if unary predicate pred returns true for at least one element in the range [first, last).
5) Checks if unary predicate pred returns true for no elements in the range [first, last).
2,4,6) Same as (1,3,5), but uses r as the source range, as if using ranges::begin(r) as first and ranges::end(r) as last.
Notwithstanding the declarations depicted above, the actual number and order of template parameters for algorithm declarations is unspecified. Thus, if explicit template arguments are used when calling an algorithm, the program is probably non-portable.
Parameters
first, last - the range of the elements to examine
r - the range of the elements to examine
pred - predicate to apply to the projected elements
proj - projection to apply to the elements
Return value
1-2) true if pred returns true for all elements in the range, false otherwise. Returns true if the range is empty.
3-4) true if pred returns true for at least one element in the range, false otherwise. Returns false if the range is empty.
5-6) true if pred returns true for no elements in the range, false otherwise. Returns true if the range is empty.
Complexity
1-6) At most last - first applications of the predicate and last - first applications of the projection.
Possible implementation
First version
Second version
Third version
Example
// Run this code