I'm writing a small library for quantum mechanics and I want to use expression template to form operator expressions. Especially forming the Hamiltonian with expression template.
I basically followed this source to construct the code and overloading the corresponding operators + * -: https://en.wikipedia.org/wiki/Expression_templates
Forming the expression for the Hamiltonian requires a sum
Vec x = u_1 + u_2 + ... + u_N
where N is a (const) integer and u_i are also of type Vec. Writing this expression in the code works but I would like to be able to write
Vec x = Sum_{i=0}^{N} u_i
How would one do this?
------------ EDIT ------------
After some research and with the help of the comments, I came up with an idea of static for loop... After googling I found an article in http://www.drdobbs.com/loops-metaloops-c/184401835?pgno=8 which is exactly what I needed.