Boost logo

Boost :

From: Korcan Hussein (korcan_h_at_[hidden])
Date: 2005-10-21 15:05:20


Hi I'm not sure if this has already been explored or even in current use but
I think I may have come up with an alternative solution to the type
deduction of intermediate results from expression templates.

Instead of using automatic type erasing technique, take the compile-time
parse tree of an intermediate expression and create an exact runtime replica
of the expression tree using recursive variant types (using Boost.Variant in
C++). The creation of the expression tree can be completely automated.

I have tried this myself with promising results. The only (minor) downside
is in order to avoid redundant copies of operands the types of the operands
must be given but not the structure of the compile-time expression tree
itself. Leaf nodes of the recursive variant hold constant references to
there elements.

I've done quick profile of this against the traditional eager evaluation of
overloaded operators and it still is more efficient but tree creation does
cost in time slightly.

If people are interested I can post code the code for this.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk