2008shivam / github-slideshow

A robot powered training repository :robot:
https://lab.github.com/githubtraining/introduction-to-github
MIT License
1 stars 0 forks source link

Automatic code generation in C++ #2

Open 2008shivam opened 3 years ago

2008shivam commented 3 years ago

I want a piece of code which does not involve loops but automatically generates some C++ code.

I have an const int d, and from this I want to write d lines of code to access an array. So for instance

for(int k=0; k<d;++k){ // do something to myarryay[k]; }

but I don't want to write this in a for loop. I want the complier to execute as if the following lines of code was written:

do something to myarray[0] do something to myarray[1] . . . do something to myarray[d]

Can anyone give me a suggestion on some code that does this?