C++11 typelist unroller and proxy caller of static functions
c++, c++11, templates
Solution
Pack expansion needs an unpacking context and array construction is one of those. Without recursion:
static void callFoos() {
int unused[] = {(T::foo(), 0)...};
(void)unused; // suppress warnings
}
Same for `callBars`.
Problem
Is there a simple way to do this in C++11? I'd like to keep both the multiple inheritance AND ability to cycle thru all the static functions in the pack, if possible. ``` #include <cstdio> struct A { static void foo() {printf("fA\n");} static void bar() {printf("bA\n");} }; struct B { static void foo() {printf("fB\n");} static void bar() {printf("bB\n");} }; struct C { static void foo() {printf("fC\n");} static void bar() {printf("bC\n");} }; template <typename... T> struct Z : public T... { static void callFoos() { /* ???? WHAT'S THE SYNTAX T...::foo(); T::foo()...; */ } static void callBars() { /* ???? WHAT'S THE SYNTAX T...::bar(); T::bar()...; */ } }; int main() { Z<A, B, C>::callFoos(); Z<A, B>::callBars(); } ```