template<class... Args> void f(Args... args) {
auto x = [args...] { return g(args...); };
x();
}
https://msdn.microsoft.com/ja-jp/library/dd293608.aspx
ご存知の方教えてくださいませんか。
template<class... Args> void f(Args... args) {
auto x = [args...] { return g(args...); };
x();
}
これは、間違っています。(少なくともC++では)Math さんが書きました:... はコンピュータでは”たくさんの”を意味します。It's means " ... is many"(たくさんとは複数のという事です)
//可変個引数テンプレート関数の機構について説明するには、これを使用して printf の機能の一部を変更するのが最も適切です。
#include <iostream>
using namespace std;
void print() {
cout << endl;
}
template <typename T> void print(const T& t) {
cout << t << endl;
}
template <typename First, typename... Rest> void print(const First& first, const Rest&... rest) {
cout << first << ", ";
print(rest...); // recursive call using pack expansion syntax
}
int main()
{
print(); // calls first overload, outputting only a newline
print(1); // calls second overload
// these call the third overload, the variadic template,
// which uses recursion as needed.
print(10, 20);
print(100, 200, 300);
print("first", 2, "third", 3.14159);
}
//出力
//--------------------------------------------------------------------------------
// 1
// 10, 20
// 100, 200, 300
// first, 2, third, 3.14159