Have anybody implement Ada-style modulo types

https://en.wikibooks.org/wiki/Ada_Programming/Types/mod

in D?

I'm thinking

modulo.d:

struct Mod(size_t m, Block = uint)
{
    static assert(m <= 2^^(8*Block.sizeof));
    Block value;
}

typically used as

Mod!(8, ubyte)
Mod!(256, ubyte)
Mod!(8, uint)

?

Reply via email to