Variadic templates

前端 未结 8 1918
野趣味
野趣味 2020-12-06 00:05

I have seen a lot of links introducing the variadic templates. But I have never seen any compilable example that demonstrates this approach.

Could someone provide me

8条回答
  •  -上瘾入骨i
    2020-12-06 00:39

    Before C++11, you can create template only with the fixed count of parameters.

    Firts template for the function with one parameter.

    Second template for the function with two parameters. ... i.e.

    Since C++11 you can write only one template, compiler will generate required function itself.

    Good example http://eli.thegreenplace.net/2014/variadic-templates-in-c/

提交回复
热议问题