Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2003-11-19 23:29:06

"Andy Little" <andy_at_[hidden]> wrote in message
> "Andy Little" <andy_at_[hidden]> wrote in message
> news:bphbjf$buc$
> [snip]
> > The programmer imposes a type on the entity when it is ouput.
> > A physical quantity consists in a concise amount of information. Keep it
> > simple.
> > e.g
> > pq_length<value_type>::m length1(1), length2(1);
> > pq_angle<value_type>::radians alpha = length1/length2;
> > pq_angle<value_type>::degrees beta = length1/length2;
> Hoisted on my own rope !
> It 's probably not possible to convert to degrees in that example without
> dimensionless type.
> You win on this one ... C'est la vie :-)

OTOH. Angles are important enough to have their own identity and should not
be dependent on the pq class.
value_type val ;
pq_angle<value_type>::radians alpha(val); // ok
pq_angle<value_type>::degrees beta(val); // ok
pq_angle<value_type>::radians alpha = val ; // no requires explicit value
pq_angle<value_type>::degrees beta = val ; // no requires explicit value
alpha = beta; //ok
//and there is no dimensionless type :-) hence
pq_length<value_type>::m length1(1), length2(1);
value_type val = length1/length2; //ok
pq_angle<value_type>::radians alpha = length1/length2; // no requires
explicit value ctor
pq_angle<value_type>::degrees beta = length1/length2; //no requires explicit
value ctor
pq_angle<value_type>::radians alpha( length1/length2); // ok
pq_angle<value_type>::degrees beta( length1/length2); // ok
basically no direct relationship betwen angle and pq.
Let the programmer decide

Andy Little

Boost list run by bdawes at, gregod at, cpdaniel at, john at