Boost logo

Proto :

Subject: [proto] restructuring expression
From: Karsten Ahnert (karsten.ahnert_at_[hidden])
Date: 2012-05-29 04:44:41

I have an arithmetic expression template where multiplication is
commutative. Is there an easy way to order a chain of multiplications
such that terminals with values (like proto::terminal< double >) appear
at the beginning? For example that

arg1 * arg1 * 1.5 * arg1

will be transformed to

1.5 * arg1 * arg1 * arg1


I can imagine some complicated algorithms swapping expressions and child
expressions but I wonder if there is a simpler way.

Proto list run by eric at