generic + numeric + literals = abomination

so so at
Sat Mar 27 03:20:38 PDT 2010

In C++!

I have a type defined in the core library like..
typedef float scalar;
//typedef double scalar; // <-- whole framework is now double precision

Next i instantiate vectors, matrices etc... from templates.
typedef vector_t<scalar, 3> vector;
typedef matrix_t<scalar, 3, 3> matrix;

Until now everything cool, here pain comes...

const scalar a = scalar(0.2) * math::consts<scalar>::pi; // can't drop  
cast, since 0.2 is double
const scalar b = a * scalar(0.9) + scalar(5); // " "
const vector v = vector(8.0) * scalar(3.0); // can't drop cast, error

Since D is superb, i like to know how you do it in D.
If you got a better idea in C++, i would like to hear that too!


Using Opera's revolutionary e-mail client:

More information about the Digitalmars-d-learn mailing list