Implicit type conversions with data loss
Thiez
thiezz at gmail.com
Tue Jun 5 18:07:04 PDT 2012
On Tuesday, 5 June 2012 at 22:17:57 UTC, bearophile wrote:
>
> Or you can add an assert/enforce, or you can create a small
> struct that represent safely assignable uints, etc. No solution
> is good.
>
> Bye,
> bearophile
Surely structs could work?
struct safeType(T) {
T value;
}
Define all operations that you can safely perform on T on the
struct, but only with structs of the same type and on T. It
wouldn't be very pretty, but I would work, wouldn't it? Writing
the template would be annoying but you'd only have to do it once.
More information about the Digitalmars-d
mailing list