The standard DIM() macro was not typesafe as it happily deferred errors to runtime that can be caught at compile time. Replacing it with a generic C++11 constexpr allows for typecasting, comparison and compile time error checking.