Skip to content

Instantly share code, notes, and snippets.

View anskl's full-sized avatar

Antonios Sklavos anskl

  • Amsterdam
  • 17:34 (UTC +01:00)
View GitHub Profile
@anskl
anskl / unpack.cpp
Last active July 4, 2019 13:11
C++ - Unpack variadic args without recursion
// Genereric solution - see implementations below
// Avoids recursion
template<typename... Types>
void unpack(Types... args) {
auto a = {args...}; // <a> becomes an initializer_list of type <Types>
// here we know all the input arguments
// no need for va_start etc :)
}
// Example implementation - sum