【发布时间】:2011-05-17 23:35:04
【问题描述】:
你能帮我解决这个编译器错误吗?
template<class T>
static void ComputeGenericDropCount(function<void(Npc *, int)> func)
{
T::ForEach([](T *what) {
Npc *npc = Npc::Find(what->sourceId);
if(npc)
func(npc, what->itemCount); // <<<<<<< ERROR HERE
// Error 1 error C3493: 'func' cannot be implicitly captured because no default capture mode has been specified
});
}
static void PreComputeNStar()
{
// ...
ComputeGenericDropCount<DropSkinningNpcCount>([](Npc *npc, int i) { npc->nSkinned += i; });
ComputeGenericDropCount<DropHerbGatheringNpcCount>([](Npc *npc, int i) { npc->nGathered += i; });
ComputeGenericDropCount<DropMiningNpcCount>([](Npc *npc, int i) { npc->nMined += i; });
}
我不明白为什么它给了我错误,我不知道如何解决它。 ComputeGenericDropCount(auto func) 也不起作用。
【问题讨论】:
-
你可能会觉得这很有趣:stackoverflow.com/questions/2425277/…
标签: c++ visual-studio visual-studio-2010 c++11 compiler-errors