http://d.puremagic.com/issues/show_bug.cgi?id=8220



--- Comment #10 from klickverbot <c...@klickverbot.at> 2012-06-21 14:41:40 PDT 
---
(In reply to comment #8)
> alias typeof(meter*meter)                       Area;
> alias typeof(meter*meter*meter)                 Volume;
> alias typeof(kilogram/(meter*meter*meter))      Density;

For an example of a working design similar to this, see my std.units prototype
(there didn't seem to be much interest in it, so I never actually pursued
Phobos integration so far):

https://github.com/klickverbot/phobos/blob/units/std/units.d
http://klickverbot.at/code/units/std_units.html

(the implementation is more ugly than it needs to be because of a number of
now-fixed compiler bugs, but that's not the point here)

Note how any template taking a unit type also accepts an alias to a unit
struct, thus removing the need to deal with the actual unit types in virtually
all situations, which avoids cluttering up the code with typeof() and .init.
For example, new compound units are just defined like this:

---
enum newton = kilogram * metre / pow!2(second);
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to