Boost logo

Boost Users :

Subject: Re: [Boost-users] [units][ublas] how would i use typedef in units?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-10-14 22:44:31


AMDG

Matthias Schabel wrote:
>> //get Real part from 'tension' and pretend it's a current
>> quantity<current, double> phony_tension = tension.value().real *
>> amperes;//compiler doesn't complain, but how do I prevent this to
>> compile?
>
> As soon as you use the value member function you have stripped out all
> unit information. Then, by multiplying by amperes, you are telling the
> compiler that this quantity is a current. It's not clear to me what
> you are trying to do here...the real part should still have units of
> electric potential. You might find reversing the nesting useful :
>
> typedef std::complex<quantity<electric_potential,double> > tPotencial;

I thought that the operators for std:;complex can't deduce the return type
correctly for Boost.Units. Anyway "The effect of instantiating the template
complex for any type other than float, double or long double is
unspecified." (26.2)

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net