Boost logo

Boost :

Subject: [boost] [ratio] Assignation between equivalent ratios
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-12-06 13:33:58


Hi,

I was wondering if we need to be able to make assignations between equivalent ratios. e.g.

ratio<1,3> r1;

ratio<3,9> r2;

r1 = r2; // (1)

Reading N3000 even if they are equivalents (synonym ) as its num and den are the same, there is no defined assignation. So (1) should not compile with the current recomendation.

IMO, this should compile, and so we need to add a specific assignement operator.

Other example

ratio<1,3> r1;

ratio<2,3> r2;

r1 = r2-r1; // the type of this expression could be ratio<3,9> so the compilation fails.

Otherwise the recomendation should clarify the meaning of synonym on the ratio arithmetic operators
[ratio.arithmetic] 2

"The nested typedef type shall be a synonym for ratio<T1, T2> where T1 has the value R1::num *

R2::den + R2::num * R1::den and T2 has the value R1::den * R2::den."

Maybe we should talk of normalized ratio and not of synonym. BTW, where is synonym defined?

In addition I think that we need also to add that the declaration of no normalized ratios, as ratio<3,9>, must fail at compile time as it is not normalized and we can not assigne nothing to them.

I'm missing something? Any thougths?

Best regards
_____________________
Vicente Juan Botet Escribá


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