folly::gen::all

all() - For determining whether all values in a sequence satisfy a predicate.

Synopsis

Declared in <folly/gen/Base.h>

template<
    class Predicate = Identity,
    class Filter = /* implementation-defined */,
    class IsEmpty = /* implementation-defined */,
    class Composed = /* implementation-defined */::Composed<Filter, IsEmpty>>
Composed
all(Predicate pred = Predicate());

Description

The following is an example for checking if all members of a team are cool:

bool isAwesomeTeam = from(team) | all(isCool);

Note that if no predicate is provided, 'all()'' checks if all of the values are true when cased to bool. The following makes sure none of 'pointers' are nullptr:

bool allNonNull = from(pointers) | all();

Note: Passing an empty sequence through 'all()' will always return true. In fact, 'all()' is equivilent to the composition of 'filter()' with the reversed predicate and 'isEmpty'.

from(source) | all(pred) == from(source) | filter(negate(pred)) | isEmpty

Return Value

A sink returning true if every value satisfies pred.

Parameters

NameDescription
predThe predicate tested against each value.