I have a template parameter pack that I would like to pass into a function that takes in a variable number of parameters. Since I don't know how many parameters I actually have, how can I pass in an unknown amount of parameters' data members into the function?
template <typename BarType...>
Class Test
{
explicit Test(BarType ...bars)
{
// Calling this function with parameter pack instead of this way
// (which won't even work with above parameter pack)
FooFunction(
[](BarType &bar1){ return bar1.bar_member; },
[](BarType &bar2){ return bar2.bar_member; },
[](BarType &bar3){ return bar3.bar_member; })
}
}
How can I accomplish the above FooFunction without manually listing out all three parameters (making it more dynamic)? Since there might be more parameters bar4, bar5 etc. So just manually listing them won't work.
FooFunction(bar1, bar2, bar3)not work for you?