Ask coding questions

← Back to all posts
Binding Variadic Parameters
Coder100 (17038)

Binding Variadic Parameters

Is this a stack overflow-worthy question?

Anyways, suppose I have a function here:

void urmom(size_t size, std::string name);

binding this would be quite simple:

std::bind(urmom, 500, std::placeholders::_1);

But what if I had a variadic argument function?

template <typename... T>
void urmom_n_friends(size_t size, T... friends);

// overload
void urmom_n_friends(size_t size, Mom friends);

Obviously I can't just do:

std::bind(ur_n_mom, 500, _1);

I'm thinking something about recursion (as that is how you implement such functions), but I don't know what...

Free cycles: @mocaCDEveloper @DynamicSquid @fuzzyastrocat @xxpertHacker
feel free to say hit that check mark lol

xxpertHacker (860)

I saw this and was gonna do the following:
a) Mention std::bind (but you already know about that)
b) Tell you to literally ping me from now on about C++ lol (but you already did that too)
Lmao, why did I never get the ping?
Maybe thought you were spamming.

Okay, I'm going to open up a C++ Repl and cook something up.

xxpertHacker (860)

@xxpertHacker Nvm, was solved in the SO question.

Should put it in the post/title that it has since been solved.
That's what I do when SO answers first.