template struct Half { enum { Result = N >> 1 }; }; template struct Double { enum { Result = N << 1 }; }; template struct IsEven { static const bool Result = (N & 1) == 0; }; template struct EthiopianMultiplication { template struct AddIfNot { enum { Result = Plier + RunningTotal }; }; template struct AddIfNot { enum { Result = RunningTotal }; }; template struct Loop { enum { Result = Loop::Result, Double::Result, AddIfNot::Result, Plicand, RunningTotal >::Result >::Result }; }; template struct Loop <0, Plicand, RunningTotal> { enum { Result = RunningTotal }; }; enum { Result = Loop::Result }; }; #include int main(int, char **) { std::cout << EthiopianMultiplication<17, 54>::Result << std::endl; return 0; }