在C++ 11中有一个简单的方法吗?如果可能的话,我想保持多重继承和能力循环通过包中的所有静态函数.
#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, …Run Code Online (Sandbox Code Playgroud)