
"Tobias Schwinger" <tschwinger@neoscientists.org> wrote in message news:d0k5m1$4cp$1@sea.gmane.org...
It can be difficult to add such specializations - depending on how your expression templates are implemented. It's just something to keep in mind.
Example: template<typename T, int Rows, int Cols> class matrix { LAZY_CLASS(matrix); static lazy::type<matrix> matrix_; public: //.. matrix(LAZY_OP(matrix_ + matrix_)); //.. }; template<typename T, int Rows, int Cols> matrix<T, Rows, Cols>::matrix(LAZY_OP(matrix_ + matrix_) op) { //.. } template<> matrix<int, 4, 4>::matrix(LAZY_OP(matrix_ + matrix_) op) { //Using SIMD instructions. } Enough easy?
- There should be an implicit conversion sequence that allows to evaluate a lazy expression: Already works. Example: void fun(Matrix &); Matrix a, b, c; fun(a + b * c * (a + b)); //compiles just fine.
It's nice when the cross product implementation can indicate by the paramter type of its signature that it needs an intermediate result (otherwise it would have to evalutate the expression explicitly or direction * std::sin(a*half) will be evaluated twice).
It won't be evaluated twice, AFAIK.
- Do you know the Boost.Assign technique ? I use a similar approach to have a nice syntax for initialization and inlining that works within expressions: I believe that this is not within coverage of my library. My library deals with lazy evaluation of functions and n-arity operators. Maybe I misundersand something?
-- Pavel Chikulaev