Ambiguous overload on argument-less variadic templates

吃可爱长大的小学妹 提交于 2019-11-30 18:48:18

In this question's case, since template parameters are non-type, if we prepare a function with default template argument like the following, Dummy parameter can be saved:

template<typename = void>
bool All(Param& c) {
    return true;
}

template<Func* f, Func* ...rest>
bool All(Param& c) {
    return f(c) && All<rest...>(c);
}

However, I'm not sure this is always applicable. For more general case, std::enable_if or similar dispatch might be needed (this will make the code a little lengthy though).

Jared Grubb

Looks like your question is similar to this one: Compilation Error on Recursive Variadic Template Function

There are two answers there that should work; one that is your #3.5 and the second is one you didnt have.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!