示例如下:
get_passed_dies()和get_failed_dies()函数类型为:const DieList& ()const
typedef QVector<QPair<int, int>> DieList;
typedef std::function<const DieList &()> GetDies;
注意std::function不可以加函数后的const,否则会报错。
WaferMap::DieList WaferMap::getPassedDies()
{
auto lamFunc = [=](){
return cp_die_->get_passed_dies();
};
return getPassedDies(lamFunc);
// auto func = std::bind(&common::CpDataDie::get_passed_dies, cp_die_);
// return getPassedOrFailedDies(func);
}
WaferMap::DieList WaferMap::getFailedDies()
{
auto func = std::bind(&common::CpDataDie::get_failed_dies, cp_die_);
return getPassedOrFailedDies(func);
}
WaferMap::DieList WaferMap::getPassedOrFailedDies(common::CpDataDie::GetDies func)
{
WaferMap::DieList returnDies(func().size());
auto convert = [&](){
for(auto &&die : func())
{
returnDies.emplace_back(Die(die.first, die.second));
}
};
convert();
return returnDies;
}
WaferMap::DieList WaferMap::getPassedDies(std::function<const common::CpDataDie::DieList ()> func)
{
WaferMap::DieList returnDies(func().size());
auto convert = [&](){
for(auto &&die : func())
{
returnDies.emplace_back(Die(die.first, die.second));
}
};
convert();
return returnDies;
}