Since you are using C ++, how about overloading some operator and passing arguments one by one? for instance
class MyFunction { std::vector<int> param; public: MyFunction() { } MyFunction &operator,(int eatMe) { param.push_back(eatMe); return *this; } ~MyFunction() {
Then you can call it like this:
MyFunction(),2,3,5,7;
Note. Using a comma operator may look scary, but in this case it is really very useful. This is the smallest possible left-associative operator.
If your function accepts additional parameters, and not just an unknown length of int -s, you can pass them in the constructor.
If someone uses something other than int , the default comma operator will be used (evaluate the left side, discard, evaluate the right side). If you do not like it, choose another operator, for example. stream-like << or boost-like % .
source share