あなたはこの構文を使用することができますが、それは本当に奇妙に見える:あなたはまた、より高度な処理を行うためにヘルパークラスを使用することができます
template <typename T>
using function_ptr = add_pointer_t<enable_if_t<is_function<T>::value,T>>;
template<function_ptr<void()>... Functions>
void call_all()
{
initializer_list<int>{(Functions(), 0)...};
}
:
template<void(*... Functions)()>
void call_all()
{
initializer_list<int>{(Functions(), 0)...};
}
は私もタイプを、エイリアスと思います:
using fp = function_ptr<string()>;
template<fp First, fp... Others>
struct helper
{
static void run()
{
helper<First>::run();
helper<Others...>::run();
}
};
template<fp One>
struct helper<One>
{
static void run()
{
DBG(One());
}
};
template<fp... Functions>
void run()
{
helper<Functions...>::run();
}
live demo
素晴らしいですが、パックを実際の呼び出しに展開せずに(私の例のように)別のテンプレートにパックを渡すにはどうすればいいですか?関数を1つずつ呼び出して、次の関数を呼び出す前に戻り値の型をチェックする必要があります。私の実際のテンプレートには、最初の関数と残りの2つの引数があります。 – theduke
@theduke編集を確認してください – krzaq
大変です、ありがとうございました。 ftwを使って... – theduke