【发布时间】:2011-10-13 19:36:27
【问题描述】:
这是我在这里的第一篇文章,如果我不尊重“方式和习俗”,请善待:)
我是使用 Boost::Phoenix 的新手,我想将函数传递给定义如下的方法:
template <typename Selector>
Result Greedy (
const t_Capacity& capacity,
BTSSet stations,
BTSSet startSet)
{
//...
function <Selector> sel;
while ( !stations.empty() ) {
BTSSet::iterator currentStation = sel(stations);
// ...
}
// ...
}
我的选择器功能是:
struct rouletteWheelSelector {
typedef BTSSet::iterator result_type;
BTSSet::iterator operator () ( const BTSSet& stations ) {
// ...
}
};
但是我的编译器说没有办法从 from 'typename detail::expression::function_eval<rouletteWheelSelector, set<BTS *, BTS_Cmp, allocator<BTS *> > >::type const' 转换为 BTSSet::Iterator。
我的仿函数声明好吗?如何强制编译器推断 sel 的正确返回类型?
谢谢!
【问题讨论】:
-
你试过让
rouletteWheelSelector::operator()const 吗?
标签: c++ boost boost-phoenix