软件断点的实现与调试
1. 停止点相关函数与测试
1.1 停止点函数
在处理停止点的相关操作时,有两个重要的步骤。首先,需要找到相关的停止点,将其禁用,以避免出现泄漏的停止点。然后,从容器中删除这些停止点。另外,还有一个重要的函数 for_each ,它用于遍历集合中的停止点,并对每个停止点调用传入的函数 f 。代码如下:
namespace sdb {
template <class Stoppoint>
template <class F>
void stoppoint_collection<Stoppoint>::for_each(F f) {
for (auto& point : stoppoints_) {
f(*point);
}
}
template <class Stoppoint>
template <class F>
void stoppoint_collection<Stoppoint>::for_each(F f) const {
for (const auto& point : stoppoints_) {
f(*point);
}
}
}
这里连续使用两个模板行来定义类模板的成员函数模板。 for_each 的模板参数 F 是要为集合中的每个元素调用的函数类型,它接受一个普通函数参数
超级会员免费看
订阅专栏 解锁全文
17万+

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



