Let's keep it short. Why does the following code compile successfully...
#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() {}
... and the following code does not?
#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() {}
Error:
1:30: error: expected primary-expression before 'int'
5:19: note: in expansion of macro 'RUN_FORALL'
How can I call a function template in a pack expansion pattern?