enable_if template param is lambda (with particular signature)

前端 未结 1 753
我寻月下人不归
我寻月下人不归 2021-01-21 14:10

I have something this:

template
class Image {
    Image(int w, int h, T defaultVal){
        for(int i=0; i

        
1条回答
  •  北海茫月
    2021-01-21 14:55

    You're looking for std::is_invocable:

    template>
    

    F& because you're invoking it as an lvalue, and then after that it's just a list of types of parameters.


    The above requires C++17. It is implementable on C++14, but in your case we can also take a much simpler approach and just do:

    template ()(1, 1))>
    

    F& for the same reason as above, and the rest of the expression is more familiar. Since we're calling with ints we don't care about the other things that INVOKE allows for (e.g. pointers to members).

    0 讨论(0)
提交回复
热议问题