Quote:Original post by the_edd
Quote:Original post by johnstanp
Well, the_edd, I was wondering if bignum could be a typedef, an alias of a primary type, hence removing the need of using a custom type, to select, for the same primary type, a different implementation( algorithm ).
Ah I see. No, I intended you to think of it as a user defined class.
Okay.
I could wrapp the primary types in my own classes, but I would have to overload the usual operators for those primary types.
Well, I took the most painful path, that is to say, adding a template parameter to the definition of my Vector3 class and to all of the classes that have a vector3 member object...
template<typename Real,class MathLib>class Vector3{ public: ... private: ...};...template<typename Real,class MathLib>Real Vector3<Real,MathLib>::length()const{ return MathLib::SQRT( x[0]*x[0] + x[1]*x[1] + x[2]*x[2] );}
Of course, MathLib must define static functions( for example SQRT ): I prefer doing it that way, to avoid storing an instance of MathLib, for every Vector3 instanciated...And ah, I had to overload "operator=" and "Vector3( const Vector3& )" to allow "type conversion" between two Vector3 using different "Math Libraries".
[edit] That's the solution given by lexs. So thank you lexs. And thank you the_edd for your disponibility.[/edit]