coveo::linq
Implementation of .NET-like LINQ operators in C++
Functions

Checks if all elements in a sequence satisfy a predicate. More...

Functions

template<typename Pred >
auto coveo::linq::all (const Pred &pred) -> detail::all_impl< Pred >
 Checks elements in a sequence against a predicate. More...
 

Detailed Description

The all operator scans a sequence and validates that all its elements satisfy a given predicate.

This is a terminal operator.

.NET equivalent: All

Function Documentation

◆ all()

template<typename Pred >
auto coveo::linq::all ( const Pred &  pred) -> detail::all_impl<Pred>

Scans a sequence and calls a predicate with each element. The predicate must return true if the element satisfies the predicate. The final result will indicate if all elements satisfy the predicate.

Works on empty sequences (returns true in such a case).

Use like this:

const int NUMS = { 42, 23, 66 };
using namespace coveo::linq;
bool all_big = from(NUMS)
| all([](int i) { return i >= 10; });
bool all_odd = from(NUMS)
| all([](int i) { return i % 2 != 0; });
// all_big == true
// all_odd == false
Parameters
predPredicate to satisfy.
Returns
(Once applied) true if all elements in sequence satisfy pred.