I'm relatively new to C++ and I'm currently creating a class based on a C code I was given. In this code there are some macros that define for loops. I've heard that is better to avoid macros so I'm trying (and failing) to write them differently.
I looked at this question which suggest the use of templates and functors, even though I'm not achieving what I want.
I will give a simplify example. Let's suppose that the macro is defined as
#define for_loop (g,u,v) \
for (u = g.attribute, v = g.otherAttribute ; u <= 20 ; u = g.updateAttribute, v = g.updateOtherAttribute)
And it is used in several parts of the code for different purposes.
How would you implement it without using macros in C++?