How would one call std::forward on all arguments in a variadic function?

前端 未结 1 1506
有刺的猬
有刺的猬 2020-12-04 09:22

I was just writing a generic object factory and using the boost preprocessor meta-library to make a variadic template (using 2010 and it doesn\'t support them). My function

相关标签:
1条回答
  • 2020-12-04 10:17

    You would do:

    template <typename ...Params>
    void f(Params&&... params)
    {
        y(std::forward<Params>(params)...);
    }
    

    The ... pretty much says "take what's on the left, and for each template parameter, unpack it accordingly."

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