1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// PR c++/57132 template<unsigned m, unsigned a> struct mod { static unsigned calc(unsigned x) { unsigned res = a * x; if (m) res %= m; return res; } }; int main() { mod<3,2>::calc(7); mod<0,2>::calc(7); }