C++ Variadic Function Templates of Known Type

前端 未结 4 1791
死守一世寂寞
死守一世寂寞 2021-01-04 09:43

I\'m currently trying to get my head around some of the things I can do with variadic template support. Let\'s say I have a function like this -

template <         


        
4条回答
  •  生来不讨喜
    2021-01-04 09:55

    This should work:

    void foo(int);
    
    template
    void foo(int first, Args... more)
    {
       foo(first);
       foo(std::forward(more)...);
    }
    

提交回复
热议问题