lundi 26 mars 2018

C++ Recursive Variadic Lambda

In C++ we can have a recursive variadic template function. For example:

template<typename ...H>
void g(){}
template<typename H, typename ...T>
void g(H h,T ...t){
    std::cout << h << "\t";
    g<T...>(t...);
}

However this does not seem possible to be done using lambdas. My two main main concerns are:

  • How to establish a base-case.
  • How to make a lambda be recursive and at the same time variadic.

Is this type of feature only available in more high-level kind of languages such as Javascript?

Aucun commentaire:

Enregistrer un commentaire