samedi 26 mai 2018

Variadic Template Function Call

Let's suppose we have the following variadic template function:

template <int... Ints> 
void foo() {
  Foo<Ints...> f;
  // do something with f.
}

Note that foo need a sequence of integers at compile time, in order to build Foo class.

We can simply invoke it:

foo<1, 2, ,3 , 4>();

Is there any method to "mitigate" this function call? For example, to have something like:

foo(1, 2, 3, 4);

Notes:

  • No C-style (Macro, or vargs).
  • foo needs compile time sequence of integers.
  • Any C++ standard is fine.

Aucun commentaire:

Enregistrer un commentaire