On Friday, 26 October 2012 at 13:55:35 UTC, simendsjo wrote:
Not sure if this is a bug or intended behavior:
...
So.. What do I need to implement for a struct to be a valid
built-in type?
All valid properties (min, max etc) and operators for that type?
I am looking for something similar. I ended up looking at Proxy
in typecons because the description says "// Enable operations
that original type has". So for instance it looks like you could
wrap an int or double in a struct and it is almost exactly like
an int or a double. Presumably you could then overload just the
changes (min/max for range, etc). I've found issues for my case,
but at least its worth a look.
http://forum.dlang.org/post/[email protected]
If I try to check that this struct is numeric, unfortunately it
is not.
writeln("Is numeric ", isNumeric!CcRate); // false
writeln("Is numeric ", isNumeric!double); // true
-----
struct CcRate {
private double rate = 0;
mixin Proxy!rate;
this(double rate) {
this.rate = rate;
}
}
----
Thanks
Dan