Suppose I have the following code:
template <typename... Args>
void DoSomething(const Args&... args)
{
for (const auto& arg : {args...})
{
// Does something
}
}
Now let's say I'm calling this from another function, and want to pass in an std::vector
(or somehow modify the vector in such a way that it could be used with this)
void DoSomethingElse()
{
std::vector<int> vec{50, 60, 25};
DoSomething(??); // <- Ideally I'd pass in "vec" somehow
}
Is there anyway to do this? I've also considered using std::initializer_list
instead of variadic templates, but the issue still remains that I have no way to passing in existing data.
Thank you.
Aucun commentaire:
Enregistrer un commentaire