add count_if to smart ranges
This commit is contained in:
committed by
Patrick Schmidt
parent
c23d410cb0
commit
6c392fd18f
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user