Boost logo

Boost :

From: Jan Langer (jan_at_[hidden])
Date: 2004-01-09 07:09:40


Andy Little wrote:
> #include "../pqs.hpp"
> #include <complex>
> using namespace physical_quantities;
>
> int main()
> {
> std::complex<q_voltage::V> V(q_voltage::V(1),q_voltage::V(1));
> std::complex<q_current::A> I(q_current::A(1),q_current::A(1));
> std::complex<q_resistance::R> Z(q_resistance::R(1),q_resistance::R(1));
>
> // Z = V/I;
>
> typedef std::complex<double> value_type;
> pq_voltage<value_type>::V VV;
> pq_current<value_type>::A II;
> pq_resistance<value_type>::R ZZ;
>
> // ZZ = VV/II;
> }
>
> Compiles this far (VC7.1).... but no calcs
>
> First (complex using pq value_type) is I think only specialised for
> inbuilts...
> Must have ctor args as shown to get this far.

its good to hear, but i dont think many people will like this form. its
just not really intuitive. it may be needed in some scenarios, but imho
not in the field of complex values in electronics.

> Second (mine using complex value_type) Is set up for inbuilts only... stalls
> in my math_promote<A,B>::type mechanism.
> which is set up to return a void type on non-inbuilts
> Would need to put std::complex somewhere in the promotion hierarchy, perhaps
> by interrogating its value_type
>
> Interesting... perhaps could be made to work either way :-)

it should. that fact that complex is only specialized for real inbuilt
numbers is not your mistake. but we could consider some other really
generic data-type from boost, like boost::rational. this type promotion
stuff is also a lot of work, but it should definitly be in its own
library. and i have not a lot of knowledge about this.
jan

-- 
jan langer ... jan_at_[hidden]
"pi ist genau drei"

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk