C++11 lambda and template specialization

后端 未结 2 740
忘了有多久
忘了有多久 2021-02-06 17:05

I would like to know what is the correct type definition for the lambda presented below, so that the following code will compile using a conformant c++11 compiler:



        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-06 17:53

    It's std::function. Or possibly just bool(*)(int) if you prefer, since the lambda doesn't capture.

    (The raw function pointer might be a bit more efficient, since std::function does (at least in some cases) require dynamic allocation for some type erasure magic.)

提交回复
热议问题