이 구문을 사용할 수 있습니다,하지만 정말 이상한 같습니다 또한 고급 처리를 수행하는 도우미 클래스를 사용할 수 있습니다
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
위와 같은 방법으로 팩을 실제 템플릿으로 확장하지 않고도 다른 템플릿으로 전달할 수 있습니까? 다음 함수를 호출하기 전에 함수를 하나씩 호출하고 반환 유형을 확인해야합니다. 내 실제 템플릿에는 첫 번째 함수와 나머지 팩이라는 두 개의 인수가 있습니다. – theduke
@theduke가 편집을 확인합니다. – krzaq
굉장합니다, 고마워요. ftw 사용 중 ... – theduke