py::builtins::all

Defined at <pypp/builtins/all.hpp>

template <class type>
constexpr bool all(const type& iterable);

Checks whether every element of an array is true.

Note

Calling this function is equivalent to the following:

iterable[0] && iterable[1] && iterable[2] && ...

Template parameters

type: The type of iterable object.

Requirements of type

type must iterable with for loop and elements stored by the iterable object must be bool or implicitly convertable to bool.

Parameters

iterable: An iterable object.

Return value

Whether every element of the iterable is true.

Complexity

Linear in the size of iterable at most.

Example

#include <pypp/builtins/all.hpp>
#include <pypp/builtins/list.hpp>
#include <pypp/builtins/print.hpp>

int main()
{
    py::list<bool> a = {true, true};
    py::print(py::all(a));
}

Output:

true