Variadic Templates pack expansions

后端 未结 2 1931
遇见更好的自我
遇见更好的自我 2021-02-08 11:42

In Andrei\'s talk on GoingNative 2012 he talks about Variadic Templates, and he explains at one point by way of the example underneath how the parameter pack expansions work. B

2条回答
  •  走了就别回头了
    2021-02-08 12:17

    KennyTM's answer is perfect. I just also like samples. But since his answer is abstract, I didn't feel like adding demos to his answer is the correct thing. So demos for his answer are here. I'm assuming his answer is right, I know nothing myself. (If you upvote this, upvote his too)

    Obviously this is all psudocode just showing the expanded states.

    void foo(nullptr, 32, '7', "BANANA") {
        //gun(A::hun(vs)...);
        gun(A::hun(nullptr)
           ,A::hun(32)
           ,A::hun('7')
           ,A::hun("BANANA")
           );
        //gun(A::hun(vs...));
        gun(A::hun(nullptr, 32, '7', "BANANA");
        //gun(A::hun(vs)...);
        gun(A::hun(nullptr)
           ,A::hun(32),
           ,A::hun('7'),
           ,A::hun("BANANA")
           );
    }
    

提交回复
热议问题