Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tutorials and Introductions to C++ Expression Templates

What are good introductions to the creation of C++ expression template systems? I would like to express arithmetic on user defined types while avoiding temporary values (which may be large), and to learn how to do this directly rather than applying an existing library.

I have found Todd Veldhuizen's original paper and an example from the Josuttis C++ Templates book, and an article by Kreft & Langer. It is mentioned in Lecture 6 of a course on Modern C++, referring back to Josuttis.The POOMA library background introduces expression templates nicely.

I am looking for simple, clear expositions.

like image 833
grrussel Avatar asked Mar 26 '10 21:03

grrussel


3 Answers

I found Expression Templates Demystified to be fairly well explained. It starts off by showing how to implement mathematical expressions without templates and shows the basic building blocks and concepts.

The second part of the article shows how to refactor the initial implementation to use templates instead for improved performance and reduced code.

IMO, the article is a good alternative to the expression template chapter in 'C++ Templates: The Complete Guide'.

like image 94
greatwolf Avatar answered Nov 04 '22 02:11

greatwolf


You should get a copy of C++ Templates: The Complete Guide.

The code example to which you link doesn't have the accompanying text, which is quite helpful (the chapter on expression templates is 22 pages long). Without the text, all you have is code without any comments or explanation as to what it does and how and why it does it.

like image 33
James McNellis Avatar answered Nov 04 '22 04:11

James McNellis


I strongly encourage to look up Eric Niebler Boost.Proto library. A very fine introduction materials can be found over C++-next :

http://cpp-next.com/archive/2010/08/expressive-c-introduction/

and his talk at boost'con 2010 is also very interesting

like image 2
Joel Falcou Avatar answered Nov 04 '22 03:11

Joel Falcou