|
Boost : |
From: Andy Little (andy_at_[hidden])
Date: 2004-01-09 06:26:46
"Andy Little" <andy_at_[hidden]> wrote
> "Jan Langer" <jan_at_[hidden]> wrote
> > Andy Little wrote:
> > > std::complex<q_impedance::R> Z=
> > > std::complex<q_voltage::V>() / std::complex<q_current::I>().
> > >
> > > No idea if that would actually work though.... Anybody ...?
> >
> > it is correct. but i would prefer
> >
> > typedef std::complex <double> value_type;
> > voltage <value_type> v (value_type (2, 3));
> > current <value_type> i (value_type (1, 4));
> > impedance <value_type> z = v / i;
> >
> > my point is just that std::complex <double> is the value type and should
> > replace your implicit (i know its only for convenience) double.
> > jan
>
> Will try to compile and see what happens.
#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.
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 :-)
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