Is there an easy way to do this in C ++ 11? I would like to preserve both multiple inheritance and the ability to loop through all the static functions in a package, 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 THE SYNTAX T...::foo(); T::foo()...; */ } static void callBars() { /* ???? WHAT THE SYNTAX T...::bar(); T::bar()...; */ } }; int main() { Z<A, B, C>::callFoos(); Z<A, B>::callBars(); }
source share