Compiler error C3493: 'func' cannot be implicitly captured because no default capture mode has been specified

后端 未结 1 839
天命终不由人
天命终不由人 2021-01-31 02:59

Can you help me resolve this compiler error?

template
static void ComputeGenericDropCount(function func)
{
    T::ForEach(         


        
相关标签:
1条回答
  • 2021-01-31 03:32

    You need to specify how to capture func into the lambda.

    [] don't capture anything

    [&] capture-by-reference

    [=] capture-by-value (copy)

    T::ForEach([&](T *what) {
    

    I'd also recommend that you should send func by const reference.

    static void ComputeGenericDropCount(const function<void(Npc *, int)>& func)
    
    0 讨论(0)
提交回复
热议问题