|
Boost : |
From: Andy Little (andy_at_[hidden])
Date: 2004-01-05 16:09:03
"Dan W." <danw_at_[hidden]> wrote in message
news:btc7ff$min$1_at_sea.gmane.org...
> > Yep... or come out of the physical_quantities system for things it cant
> > handle and use a good ole double,
> > Works a charm :-)
>
> No it doesn't! :-)
A value_type will always fulfill the role, but it is weakly typed.
I assume you are alluding to my use of ints for the
abstract-physical-quantity part of the physical-quantities type.
e.g
p_quantity<abstract_pq<1,0,0,0,0,0,0>,0,0> length;
I find that simple and expressive... but limiting.
Maybe named powers-of-dimension would be a better bet. I could start using
enums and then maybe use types.
Of course I shot that idea down pretty quickly saying it was a bit ugly.
maybe I was wrong.
The favoured boost solution is 'use a rational type'. Maybe .. but rational
fractions are a limited set.
So some time down the road someone will want to use pi().
Use a fixed type... maybe too... but accuracy is limited.
Use a floating type... but bang goes the compile time aspect.
After this there will be further math requirements.
The abstract type is used in type comparisons so if compile time math is
limited to integer.
Of course all this sounds great in theory, trivial on the page.. 'it only
needs implementing'.
I will bear all that in mind (A working demo of other peoples ideas is a lot
more useful to me than just suggestions)...and follow events... meanwhile my
solution, workaround call it what you will is as previously.
I have been presented with various objection on this thread. I assume that
when the tail goes quiet the problem has been solved.
Either that or it was just a passing jab by someone who is not very
interested
My current solution for my pqs type is: Where the physical-quantities type
cant fulfill what you want fall back on old style inbuilts.
The resulting code may be full of holes but may give a flavour of coding
with strongly typed physical-quantities.
Alternatively if you have better ideas on physical-quantities... build your
own working code, which I can run and use and I will be happy to evaluate
your version.
As I have said before... show me the better implementation with all the
problems solved and I shall delete my type from the collective
consciousness.
After all the talk of a type that will fulfill every need for every user ...
it had better be PDG.
Meanwhile I am waiting.
Try out my examples as they are ... (gcc 3.2, VC7.1 ... I hope will work on
close conforming compilers.... feedback on compile run would be very
helpful).
http://www.servocomm.freeserve.co.uk/Cpp/pqs-1-00-01/download.html
Whether you dont like the syntax, the lack of boostisms, the implicit
conversions or anything else , They will give you some basic flavour of
coding with physical-quantities.You may decide in practise that there is no
advantage over inbuilts. That in itself would be useful feedback... then we
could all pack up and go home
regards
Andy Little
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk