Skip some arguments in a C++ function?

Not directly, but you might be able to do something with std::bind:

int func(int arg1 = 0, int arg2 = 0, int arg3 = 0);

// elsewhere...
using std::bind;
using std::placeholders::_1;
auto f = bind(func, 0, _1, 0);

int result = f(3); // Call func(0, 3, 0);

The downside is of course that you are re-specifying the default parameters. I’m sure somebody else will come along with a more clever solution, but this could work if you’re really desperate.

Leave a Comment