【发布时间】:2011-05-03 23:09:28
【问题描述】:
我这样定义一个方法:
template <class ArgT>
void foo(ArgT arg, ::boost::function< void(ArgT) > func)
{
func(arg);
}
并像这样使用它——例如——:
foo(2, [](int i) -> void { cout << i << endl; });
为什么编译器不能推断出类型,因为它肯定是int?
我收到'void foo(ArgT,boost::function<void(ArgT)>)' : could not deduce template argument for 'boost::function<void(ArgT)>' from 'anonymous-namespace'::<lambda0>'。
【问题讨论】: