相关疑难解决方法(0)

从函数的参数构建模板?

template<class... Foos> // N = sizeof...(Foos)
template<typename... Args> // M = sizeof...(Args)
void split_and_call(Args&&... args)
{
    // Using Python notation here...
    Foos[0](*args[:a]);  // a = arity of Foos[0]
    Foos[1](*args[a:b]); // b-a = arity of Foos[1]
    ...
    Foos[N-1](*args[z:M]); // M-z = arity of Foos[N-1]
}
Run Code Online (Sandbox Code Playgroud)

假设:

  • 所有类型Foos都可以调用
  • 所有类型Foos都是明确的
  • 任何类型都Foos可能具有0的arity
  • Args 是所用的所有参数类型的串联 Foos

这可以在公开Foos 公平的情况下完成Args吗?即使我明确地列出了它们,我实际上也不确定该怎么做.

c++ template-meta-programming variadic-templates c++14

4
推荐指数
1
解决办法
220
查看次数