Pregunta

Suppose I want to achieve the following example effect :

if (i) j--;

Now I want to insert that line in my program as many times as I want repeatedly. If I wanted to insert that statement 1000 times then I'd have to copy paste it manually.

The purpose is to insert statements in the program and not just achieve the same logical behaviour.

I would like to use a macro that given a statement and an n inserts the statement n times in the program. I think this is possible using some Boost library macro. But I have never used Boost and I don't know which one should I use. Also I am restricted to C and not C++, but I believe that this boost macro should work in C as well.

I want to what to use and how to use it to achieve this effect

¿Fue útil?

Solución

You are looking for BOOST_PP_REPEAT.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top