|
Boost : |
From: eford_at_[hidden]
Date: 2001-09-15 16:13:56
> This looks good to me. It's exactly what I have but without using
> the boost classes (which makes it a lot easier and cleaner). Add
> something like
>
> template <class NewUnitType, class OldUnitType>
> NewUnitType
> unit_cast<NewUnitType,OldUnitType>(OldUnitType quantity);
right, I meant for people to provide those.
> plus classes defining derived units (ratios, powers, products),
> and you've pretty much got it all. Use template specialization to
> implement only the conversions that you want.
Well, if you want to provide for ratio and powers of units, then
you'll need a much more involved framework, one much more like
SIunits. I was asking if what you had in mind was something that did
not provide for automatically creating derived units. If you're want
something to automatically deal with derived units, I don't think my
unit_unconvertible isn't extensible that far. I think it's better
suited to something like making sure you only perform operations
involving sugar with other operations involving sugar.
> Then to define a framework for something like SIUnits, you just
> define a dimension class very similar to the unit class below that
> contains among other things
> a template constructor like
I don't think so. SIunits uses a list of ratios for each possible
dimension. I don't think you can to map such a list of ratios to a
single bounded integer.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk