小编use*_*606的帖子

C++ 11 typelist unroller和静态函数的代理调用者

在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)

c++ templates c++11

4
推荐指数
1
解决办法
213
查看次数

标签 统计

c++ ×1

c++11 ×1

templates ×1