I'm pretty new to Boost fusion and maybe my question does not make any sense. Fusion is presented as : "the fusion between runtime and compile time algorithms". I think i'm getting lost between what is done at compile time and what is done at run time in fusion.
Lets take the for_each
template, in fact they are two! the function and the metafunction.
The metafunction looks like to me as a trait class template for the for_each
function, wrong?.
taking the example of the for_each
function :
struct increment
{
template<typename T>
void operator()(T& t) const
{
++t;
}
};
vector<int,int> vec(1,2);
for_each(vec, increment());
I understand that the for_each
loop will be unfolded at compile time to produce code like
++at_c<0>(vec);
++at_c<1>(vec);
(obviously the at_c<x>
templates will also generate code to access fusion vector members)
To me, both the for_each function and metafunction are "compile time programs", wrong again?
Can someone explain me (with a simple example) what part of boost fusion is just compile time meta-programm and what is just classical compile time code?