#include <functional>
#include <algorithm>
nTotalCount= count_if(containerls.vPointers.begin(),containerls.vPointers.end(),bind2nd(compareuserinfoT(),deptmitm.ulDepartID));
nOnlineCount= count_if(containerls.vPointers.begin(),containerls.vPointers.end(),bind2nd(compareuserinfoO(),deptmitm.ulDepartID));
namespace std::
struct compareuserinfoT: binary_function<USERINFO*, unsigned long,bool>
{
bool operator()( USERINFO* &value, unsigned long uid) const
{
if (value->ulDepartID== uid)
return true;
else
return false;
}
};
std count_if用法
最新推荐文章于 2024-01-11 21:50:38 发布
本文展示了如何使用 C++ STL 中的 count_if 函数结合 bind2nd 对容器内的 USERINFO 指针进行过滤计数。通过自定义 compareuserinfoT 结构体实现了特定条件的比较逻辑。
590

被折叠的 条评论
为什么被折叠?



