本文整理汇总了C++中Traits::targets方法的典型用法代码示例。如果您正苦于以下问题:C++ Traits::targets方法的具体用法?C++ Traits::targets怎么用?C++ Traits::targets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Traits
的用法示例。
在下文中一共展示了Traits::targets方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
flow_graph<typename Traits::address_type> make_flow_graph(
Program const & program, typename Traits::address_type address, Traits const & traits)
{
typedef typename Traits::address_type address_type;
flow_graph<address_type> res;
std::vector<address_type> address_stack(1, address);
std::set<address_type> added_addresses;
while (!address_stack.empty())
{
instruction<address_type> inst = { address_stack.back(), res.target_addresses.size(), res.routine_addresses.size() };
address_stack.pop_back();
inst.last = traits.targets(program, inst.first,
std::back_inserter(res.target_addresses), std::back_inserter(res.routine_addresses));
if (inst.first == inst.last)
{
std::cout << "invalid instruction" << std::endl;
continue;
}
inst.target_last = res.target_addresses.size();
inst.routine_last = res.routine_addresses.size();
res.instr_graph.insert(std::make_pair(inst.first, inst));
for (std::size_t i = inst.target_first; i < inst.target_last; ++i)
{
if (added_addresses.insert(res.target_addresses[i]).second)
address_stack.push_back(res.target_addresses[i]);
}
for (std::size_t i = inst.routine_first; i < inst.routine_last; ++i)
{
if (added_addresses.insert(res.routine_addresses[i]).second)
address_stack.push_back(res.routine_addresses[i]);
}
}
return res;
}