|
Boost : |
From: Phil Richards (news_at_[hidden])
Date: 2005-01-31 14:19:41
On 2005-01-30, Andy Little <andy_at_[hidden]> wrote:
> Strictly speaking dimensional-analysis is only used for checking (what I
> have called) 'abstract quantities'. As soon as a value is involved you need
> units in order to decipher what the value means. Therefore IMO a
> dimensional analysis type should not have a Runtime 'value' member and
> should be limited to compile time only.
The dimensionality can be factored off into its own (compile-time)
checked chunk. To be usable there will need to be something that
uses it with a value type and delegates down all operations to that
underlying value type.
This is rather similar to the approach taken by Matthias Schabel
(apologies if I've got the spelling or name wrong), but had unit
checking as an extra field on the wrapper type. It is also
similar to the approach I use...
The type wrapper type in my library is something like:
template<
typename ValueType,
typename Dimensionality,
typename Units = no_units
>
class quantity;
Etc, etc. Robert's comment about the amount of effort to get
everything together for a boost library is pertinent - I don't have
the time to do even the cut down version to a suitably high standard
for boost.
[... other stuff I pretty much agree with elided ...]
[I said:]
> > It's all we need because *all* our interfaces to the outside world are
> > defined entirely in terms of SI units. We make unit conversion an SEP[*].
> IOW you are a user node on a generic physical quantities hub ... Let pqs
> take the strain ... :-)
The point is we don't need anybody to take the strain because their
isn't any. Unit conversion and/or unit enforcement just isn't done.
Anywhere. At all. Ever.
We just want dimensionality checking on what, in some cases, is quite
horribly complex calculations. (And I'm really hoping the "auto" type
deduction extension gets added into the new standard to make our
temporaries much easier to write!)
phil
-- change name before "@" to "phil" for email
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk