Varargs - hpgDesigns/hpgdesigns-dev.io GitHub Wiki

In order to handle functions taking any number of arguments, such as min(), max(), choose(), etc, ENIGMA implements a variadic argument class called enigma::varargs. This class simply overloads the comma operator to allow a simple macro to be used to convert function calls into stack pushes.

A simple varargs function, then, would look like this:

variant choose(const enigma::varargs& args) { // Declare the function to allow being passed a temporary
  return args.get(rand() % args.argc); // Use its size and access routines to fetch a random member
}
#define choose(x...) choose((enigma::varargs(), x)) // Define a macro to automatically wrap to the function