Can someone tell me how to fix the syntax problem below?
#include <iostream>
template <int N>
struct Thing {
static const int num = N;
};
template <int N>
struct Get {
using type = Thing<N>;
};
template <int... Is>
void foo() {
// int a[] = {(std::cout << Thing<Is>::num << '\n', 0)...}; // This compiles.
int a[] = {(std::cout << typename Get<Is>::type::num << '\n', 0)...}; // This does not.
}
int main() {
foo<0,1,2>();
}
GCC 5.1.0 says [Error] expected '(' before '<<' token. Any quick way to fix this (without writing a new function and have it called within foo)?
Aucun commentaire:
Enregistrer un commentaire