jeudi 5 mars 2015

How to call the idiom of using an array to apply a function to a variadic pack

Here is the idiom in question:



template<typename... T>
void f(T... t) {
int temp[] = {(g(t), 0)...};
}


This will be compiled as g(t0); g(t1); ..., order of function calls is guaranteed by C++11[dcl.init.list]/4.

A better version uses std::initializer_list instead of array, but it's not important here.


The question is: how should we call this idiom?


Upd:

Basically, it's the idiom which we should advise to people to use it instead of recursion,

e.g. f(H head, T... tail). Of course we can call it "An idiom which will be replaced by the Fold Expressions" but I hope there is a proper term for it.


Aucun commentaire:

Enregistrer un commentaire