-
Notifications
You must be signed in to change notification settings - Fork 0
Varargs
hpgDesigns edited this page Aug 8, 2021
·
1 revision
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 functionThis is number 1