Commit 4c15ff6e authored by Max Lyon's avatar Max Lyon
Browse files

add any of and all of to smart ranges

parent 147ae217
......@@ -116,6 +116,26 @@ struct SmartRangeT
return (1.0 / n_elements) * sum;
}
template <typename Functor>
auto any_of(Functor&& f) -> bool
{
auto range = static_cast<const RangeT*>(this);
for (auto e : *range)
if (f(e))
return true;
return false;
}
template <typename Functor>
auto all_of(Functor&& f) -> bool
{
auto range = static_cast<const RangeT*>(this);
for (auto e : *range)
if (!f(e))
return false;
return true;
}
/** @brief Convert range to array.
*
* Converts the range of elements into an array of objects returned by functor \p f.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment