The following code is giving me a compilation error: class Q64 is not a valid type for a template constant parameter
template<int GRIDD, class T>
INLINE T grid_residue(T amount) {
T rem = amount%(GRIDD);
if (rem > GRIDD/2) rem -= GRIDD;
return rem;
}
template<int GRIDD, Q64>
INLINE Q64 grid_residue(Q64 amount) {
return Q64(grid_residue<GRIDD, int64_t>(to_int(amount)));
}
Whats wrong? I am trying to specialize grid_residue
for class Q64
.
Changed syntax. Now getting error error: function template partial specialization 'grid_residue<GRIDD, Q64>' is not allowed
template<int GRIDD>
INLINE Q64 grid_residue(Q64 amount) {
return Q64(grid_residue<GRIDD, int>(to_int(amount)));
}
thanks
Functions cannot be partially specialized! Either use function overloading: template <int GRIDD> inline Q64 grid_residue(Q64 amount)
or wrap your function in a type (which can be partially specialized).