Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2006-08-21 02:38:57

"Matthias Troyer" <troyer_at_[hidden]> wrote


>> The above creates a lot of temporaries of course.
> Why? Using expression templates there will be absolutely no temporaries.

In my experiments with E.T, I found that it only became advantageous when use
with (say) a vector of more than 4 elements. Before that it seemed to create
more temporaries than eager evaluation. I seem to remember someone else backing
this up somewhere too.

The other problem with E.T. is that it affects the way you write expressions, as
you sometimes need to force the evaluation:

    template <typename T>
   void f(T t)
        std::complex<T> value(t,t);
        value * t;

   double a,b ;

    f ( a * b); // OK

    f ( ET_expression(a , times, b)); // Error No operator *
(std::complex<some_ET_expr> , <some_ET_expr>)

IOW E.T. performance isnt free...

Andy Little

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