This doesn't look like C, but here's how macros work in C:
Macro keyword is searched throughout the code. Macro keyword is replaced with its definition prior to compilation. If it is a macro with arguments, the passed arguments are replaced with the ones inside the definition.
In your case, the:
cimg_for(*this,ptrd,T)
Will be turned into the following:
for (T * ptrd = (*this)._data + (*this).size(); (ptrd--)>(*this)._data; )
While writing that, I have first copied the definition, then replaced each img
inside definition with *this
, then replaced each ptrs
with ptrd
, and lastly each T_ptrd
with T
. That's what macro definition told me to do, that's also what preprocessor does prior to compilation.
After that macro thing, there is a statement, so in the end, the loop looks like the following:
for (T * ptrd = (*this)._data + (*this).size(); (ptrd--)>(*this)._data; )
*ptrd = (T)*(--ptrs);