将功能应用于参数包的每个元素的语言功能

Language feature to apply function to each element of a parameter pack

有谁知道,如果存在允许我替换它的 c++ 语言功能的标准提案(感谢 Yakk):

template<class... ARGS>
void bar(const ARGS& ... args) {        
    auto t = { (foo(args),0)... };
    (void) t; //<- prevent warning about unused variable
}

像这样更自然的东西:

template<class... ARGS>
void bar(const ARGS& ... args) {        
    foo(args)...;
}

foo 例如一个函数,一个函数模板 and/or 一个重载的集合,其 return 类型可能为空(或者通常我不关心)。

顺便说一句,如果有人知道用 c++14 编写这个的更简洁的方法,请随时分享,但我认为,这已经在 this question

中处理了

使用 fold expression 和逗号运算符:

( void(foo(args)) , ...);

我在最近的邮件中没有看到任何进一步更改此设置的提议。