From: Hugo Duncan (hugoduncan_at_[hidden])
Date: 2003-10-14 14:30:17
David Abrahams <dave_at_[hidden]> wrote:
> Deane Yang <deane_yang_at_[hidden]> writes:
>> This works well in physics, where one knows in advance pretty much
>> all dimensions that one is going to need.
>> On the other hand, Hugo's approach would appear to allow for
>> compile-time definition of dimensions:
> Exactly as my approach does.
Yes, since the number of entries in your list can be changed.
> Tagging things with a DimensionType in that way will cause O(N^2)
> compile-time algorithms for computing the multiplication result,
> unless you use an MPL associative container, which, IIUC are not
> implemented yet. I posted a prototype a couple of weeks ago, in case
> you care.
I assume that there is a cost with either approach.
With the tagged approach the typelists have less elements.
By keeping the tags sorted i believe the cost is less than O(N^2).
I am no expert here and will happily defer to you.
>> The other quibble is that I also need fractional powers
>> of dimensions.
> The fractional power thing is strange, but OK.
Why strange? eg. it's sometimes useful to have the square root
of a length.
> That's why I suggest you look through the slides carefully. They
> provide a gentle introduction to the principles and structure behind
> the MPL.
I enjoyed reading it too!
>> I don't even know how to add fractions and reduce to lowest
>> terms in mpl yet.
Boost has a GCD compile time library.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk