Calling a function with variable number of arguments with an array in C++ (like python's * operator)

I'm trying to write a v8 module in C++; there, the functions receive a variable number of arguments in an array. I want to take that array and call a function like gettext and printf that receives a formatted string and it's necessary args. The thing is, how can one take an array and send the elements as arguments to one of those functions?

In python, I'd do something like this:

def the_function(s, who, hmany): print s%(who, hmany)

the_args = ["Hello, %s from the %d of us", "world", 3]
the_function(*the_args)

How can that be accomplished in C++? (I'm using v8 and node.js, so maybe there's a function or class somewhere in those namespaces that I'm not aware of)

1
задан Bryan Field 29 March 2011 в 17:05
поделиться