add count_if to smart ranges

This commit is contained in:
Max Lyon
2020-03-09 18:43:21 +01:00
parent b88a6c9de9
commit 227b1cd5c7

View File

@@ -353,7 +353,16 @@ struct SmartRangeT
}
template <typename Functor>
auto count_if(Functor&& f) -> int
{
int count = 0;
auto range = static_cast<const RangeT*>(this);
for (const auto& e : *range)
if (f(e))
++count;
return count;
}
};