views:

236

answers:

3

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.

+3  A: 

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.

James McNellis
Vandevoorde and Josuttis have the only really complete description. The topic is never going to be *simple*, because it's a topic that's both complicated and difficult, but they do the best job.
jwismar
A: 

You've got all the sources except for the scientific c++ book, which is really just the original paper (wrt to this topic anyway) and is pretty out dated. You could look at C++ Template Metaprogramming for more modern techniques built from the expression templates ideas, but something "simple" is not going to be readily available until it IS simple.

Noah Roberts
A: 

I suggest reviewing the Boost Operators at Boost Operators - Arithmetic. These are templated methods that extend fundamental arithmetic and comparison operations.

Thomas Matthews