让我们保持简短。为什么以下代码编译成功...
#define RUN_FORALL(pattern) (int[]){0, ((pattern), void(), 0)...}
template <typename ...Attributes>
class Foo : public Attributes... {
template <typename T>
void bar(T o) { RUN_FORALL(Attributes::value = o.getValue()); }
};
int main() {}
...以下代码没有?
#define RUN_FORALL(pattern) (int[]){0, ((pattern), void(), 0)...}
template <typename ...Attributes>
class Foo : public Attributes... {
template <typename T>
void bar(T o) { RUN_FORALL(Attributes::value = o.getValue<Attributes>()); }
};
int main() {}
错误:
1:30: error: expected primary-expression before 'int'
5:19: note: in expansion of macro 'RUN_FORALL'
如何在包扩展模式中调用功能模板?