I'm trying to implement the follwing function calling:
template<int index>
void print() {
std::cout << index;
}
constexpr int getConstexpr(int a) {
return a;
}
void function_to_template(int i) {
const int j = getConstexpr(i);
print<j>();
}
void main() {
for(int = 0 ; i < 10; i++) {
function_to_template(i);
}
}
and I got the following error:
fatal error: no matching member function for call to 'print'.
any I idea how to pass variable as parameter in c++ template ?
thanks.
Aucun commentaire:
Enregistrer un commentaire