I have the following function which can take N arguments of different types, and forwards them to N functions templated on each individual type, in this manner (example with
Just for fun, I propose the following way
template
bool func (int & cnt, Ts ... xs)
{
using unused = int[];
int i { -1 };
bool ret { true };
(void)unused { 0, ((++i == cnt ? (ret = func(xs)) : true), 0)... };
if ( ret && (cnt <= i) )
++cnt;
return ret;
}
but I don't think is a efficient way as the switch way.