hello.
A little bit of background: I have some strange multiple nested loops which I converted to flat work queue (basically collapse single index loops to single multi-index loop). right now each loop is hand coded. I am trying to generalized approach to work with any bounds using lambda expressions:
For example:
// RANGE(i,I,N) is basically a macro to generate `int i = I; i < N; ++i `
// for (RANGE(lb, N)) {
// for (RANGE(jb, N)) {
// for (RANGE(kb, max(lb, jb), N)) {
// for (RANGE(ib, jb, kb+1)) {
// is equivalent to something like (overload , to produce range)
flat<1, 3, 2, 4>((_2, _3+1), (max(_4,_3), N), N, N)
the internals of flat are something like:
template<size_t I1, size_t I2, ...,
class L1_, class L2, ..._>
boost::array<int,4> flat(L1_ L1, L2_ L2, ...){
//boost::array<int,4> current; class or static variable
// basically, the code below this is going to be done using recursion templates
// but to do that I need to apply lambda expression to current array
// to get runtime bounds
bool advance;
L2_ l2 = L2.bind(current); // bind current value to lambda
{
L1_ l1 = L1.bind(current); //bind current value to innermost lambda
l1.next();
advance = !(l1 < l1.upper()); // some internal logic
if (advance) {
l2.next();
current[0] = l1.lower();
}
}
//...,
}
my question is, can you give me some ideas how to write lambda (derived from boost) which can be bound to index array reference to return upper, lower bounds according to lambda expression?
thank you much
bummers, lambda only supports three placeholders.