回答編集履歴

1

appendix

2017/06/02 13:58

投稿

yohhoy
yohhoy

スコア6191

test CHANGED
@@ -101,3 +101,41 @@
101
101
  }
102
102
 
103
103
  ```
104
+
105
+
106
+
107
+ ---
108
+
109
+ おまけ:[最新のC++機能](http://faithandbrave.hateblo.jp/entry/2016/12/07/185947)をつかうと下記のように書くこともできます。(もはや"個数"が不要なのですが、必要なら`sizeof...(args)`で取得可能です)
110
+
111
+
112
+
113
+ ```C++
114
+
115
+ #include <stdio.h>
116
+
117
+
118
+
119
+ template<typename... Ts>
120
+
121
+ int func(Ts... args) {
122
+
123
+ //printf("count=%zu\n", sizeof...(args));
124
+
125
+ return (args + ...);
126
+
127
+ }
128
+
129
+
130
+
131
+ int main() {
132
+
133
+ int sum = func(1, 2, 3);
134
+
135
+ printf("%d\n", sum);
136
+
137
+ }
138
+
139
+ ```
140
+
141
+