Forwarding arguments to template member function

后端 未结 1 1904
无人共我
无人共我 2021-02-19 22:04

ideone example


I need to forward some predefined arguments plus some user-passed arguments to a member function.

#define FWD(xs) ::std::forward<         


        
相关标签:
1条回答
  • 2021-02-19 22:18

    I compiled your code in gcc 4.9 by providing template arguments to the member function pointer; like this

    int main(){
    // Compiles
    forwarder(&example::f0, 10);
    //Does not compile
    forwarder(&example::f1, 10);
    //Does compile, instantiate template with int or what ever you need
    forwarder(&example::f1<int>,10)
    }
    

    I believe what is going on is that you need to instantiate the template member function. does that change your interface too much? I think any answer will revolve around instantiating that member template somehow.

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