Boost logo

Boost :

From: Dan W. (danw_at_[hidden])
Date: 2004-01-12 05:55:34


Anatoli Tubman wrote:
> I agree that the underlying type should be a template parameter.
> I just want to note that support of std::complex would require
> operators with mixed underlying types. That is,
>
> template <typename u1, typename u2, typename v1, typename v2>
> unit<unit_product_type<u1, u2>::type, number_product_type<v1, v2>::type>
> operator* (unit<u1, v1>, unit <u2, v2>) { ... }
>
> rather than
>
> template <typename u1, typename u2, typename v>
> unit<unit_product_type<u1, u2>::type, v>
> operator* (unit<u1, v>, unit <u2, v>) { ... }
>
> This is because one would frequently need to multiply a complex by a real.
>
> Maybe std::complex< unit<electric_current, double> > is not such a bad idea?
>

That would be needed anyways, some quantities maybe best expressed in
ints. Some in shorts, or even in chars... In a 3D vis. program I'd use
double for the matrix stack only; for everything else floats are fine.
  In a CAD software I'd never use a float or double; everything there
is fixed point...


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