#pragma once namespace Math { // Returns the least nonnegative remainder of a % b. // Euclidian definition of modulo. template auto mod(A a, B b) -> decltype(a % b) { return (a % b + b) % b; } }