variableargumentlists

storing a type's type for processing variable argument lists

Is it possible to do something along the lines of: type t = int;//this would be a function which identifies what type the next argument is if( t == int ) printf( "%d", va_arg( theva_list, t ) ); in a relatively trivial way? The only object I know which can hold a type is type_info and I can't work out how to use it in this way. T...

Why doesn't Java's main use a variable length argument list?

I have a question about the syntax of the Java main declaration: public static void main (String[] args) Since you can pass a variable number of Strings when invoking the main function, shouldn't this be a variable length argument list rather than an array? Why would a command-line invocation of this method with a list of string param...

C++ Template Class Constructor with Variable Arguments

Is it possible to create a template function that takes a variable number of arguments, for example, in this Vector< T, C > class constructor: template < typename T, uint C > Vector< T, C >::Vector( T, ... ) { va_list arg_list; va_start( arg_list, C ); for( uint i = 0; i < C; i++ ) { m_data[ i ] = va_arg( arg_list, T...

How can I modify pointers passed as part of a variable argument list?

I have a function which takes a variable number of pointers, which I would like to modify. It looks something like: void myPointerModifyingFunction (int num_args, ... ) { void *gpu_pointer; char mem_type; va_list vl; va_start(vl,num_args); for (int i=0;i<num_args;i++) { gpu_pointer=va_arg(vl,void*); ...

Variable Argument list with no named argument?

Is it possible to have a function with variable arguments and no named argument? For example: SomeLogClass("Log Message Here %d").Log(5); SomeLogClass("Log Message Here %d").Error(5); ...

Double variable argument list.

I need something like this: class Node (left : Node*, right : Node*) I understand the ambiguity of this signature. Is there a way around it better than the following? class Node (left : Array[Node, right : Array[Node]) val n = new Node (Array(n1, n2), Array(n3)) Maybe some kind of separator like this? val n = new Node (n1, n2, Se...

Using a function with variable argument strings

I was playing around a bit with functions with variable arguments, and decided to make a function to create vectors with the arguments. My function for creating an int vector worked... vector<int> makeIntVector(int numArgs, ...) { va_list listPointer; va_start(listPointer, numArgs); vector<int> made; for(int a = 0; a < n...

How to pass args to method in java, like f(*args) in python?

In python, I can do: args = [1,2,3,4] f(*args) # this calls f(1,2,3,4) Is this possible in java? to clarify - f has an argument list of variable length. ...

How to pass variable number of parameters from one function to another?

Is there any way to directly pass a variable number of arguments from one function to another? I'd like to achieve a minimal solution like the following: int func1(string param1, ...){ int status = STATUS_1; func2(status, param1, ...); } I know I can do this using something like the following, but this code is going to be duplica...

How to print values of variable arguments in C?

I have a function void func(int x, char *str, ...) { ... } I am invoking it as follows: func(1, "1", "2", "3"); How can I print the values of all the extra arguments (2, 3) in function? ...

What is better for the parameters of a C callback function: va_list, or ellipsis?

My library offers a callback point where my library users can register to get information. The general form of the callback is an int followed by various parameters whose type depend on the int value. Therefore, I defined the callback type and the function to set it as follows. typedef void (* callback_func_t)(int type, ...); void set_c...