Boost logo

Boost Users :

Subject: Re: [Boost-users] [units][ublas] how would i use typedef in units?
From: Matthias Schabel (boost_at_[hidden])
Date: 2009-10-14 23:03:10


>>> //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)

Right, as usual... Maybe flesh out the more flexible complex type that
we provided in our example or lobby the standards committee to make
std::complex less stupid? Is there any good reason to have unspecified
behavior for std::complex for UDTs?

Matthias


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