Expression templates

Bill Baxter dnewsgroup at billbaxter.com
Tue Oct 24 20:21:48 PDT 2006


I thought there was a big discussion on expression templates before, but 
I can't seem to find it.

Anyway, I thought I'd see how it worked, so tried porting some code from 
  here:
   http://www.flipcode.com/articles/article_fastervectormath.shtml


The result was that the expression template version was much slower than 
just doing a plain assignment.  But it does work.  I mean you can write 
c ~= a + b, it creates an expression object and evaluates it only when 
writing it to c via opCatAssign.

This is a very primitive version of expression templates in that ... 
there aren't any templates!  It only creates an expression object out of 
one thing: the addition of two vectors.  But according to the flipcode 
page this should already be faster than the straighforward add (though I 
don't really see why).

I don't have any more time to spend on it but I thought I'd post it here 
if someone was interested in tinkering with it.

--bb
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: simpleexpr.d
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20061025/3440936c/attachment.ksh>


More information about the Digitalmars-d mailing list