I would like to build a set of pixel conversion routines that I can add together to efficiently transform pixels in an inner loop.
So, for example
template<typename op1, typename op2, .... typename opN> trans(uint8_t data, uint32_t w, uint32_t h){
uint64_t index = 0;
for(uint32_t j = 0; j < h; ++j)
for(uint32_t i = 0; i < h; ++i) {
data[index] = opN(opN-1 .....op1(data[index]));
index++
}
}
and I want the compiler to inline all ops so that this is efficient as if I explicitly defined the operations by hand in the inner loop.
Is this possible ? If I use the inline
key, and the ops are simple, can I guarantee
that compiler will remove function calls and inline everything ?