std.experimental.checkedint is ready for comments!
Nordlöw via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jun 14 03:39:01 PDT 2016
On Tuesday, 7 June 2016 at 08:50:07 UTC, Robert burner Schadek
wrote:
> PR: https://github.com/dlang/phobos/pull/4407
I also have
https://github.com/nordlow/phobos-next/blob/master/src/bound.d
providing Ada-style range type at
https://github.com/nordlow/phobos-next/blob/master/src/bound.d#L286
and
https://github.com/nordlow/phobos-next/blob/master/src/modulo.d
providing Ada-style module type at
https://github.com/nordlow/phobos-next/blob/master/src/modulo.d#L46
I'm currently using `Mod` in an useful way here
https://github.com/nordlow/phobos-next/blob/master/src/typecons_ex.d#L227
unittested here
https://github.com/nordlow/phobos-next/blob/master/src/typecons_ex.d#L286
to automatically get bounded integers when searching for elements
in static arrays. In turn, I'm using this in my radix tree
implementation here
https://github.com/nordlow/phobos-next/blob/master/src/trie.d#L922
to provide more type-safe indexing of statically sized arryas.
I know, it's big, but it *is* motivated when accessing static
arrays in specialized containers like radix trees.
Have you thought about extending checkedint to something similar
to bounded integer wrapper type like my `bound.d`?
Not that my `Bound`-type probably should be used inplace of
`Mod`, but I haven't had time to do the switch yet.
More information about the Digitalmars-d
mailing list