add count_if to smart ranges

This commit is contained in:
Max Lyon
2020-03-09 18:43:21 +01:00
committed by Patrick Schmidt
parent c23d410cb0
commit 6c392fd18f

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;
}
};