By "runtime metaprogramming" I mean changing the actual code at runtime.
For example, take this code:
while (true) {
if (flag) {
//do stuff
}
//do other stuff
}
Let's say something happens so that flag will always be false/true, so there is no need to keep checking its value. It would be nice to just "get rid" of the if statement. Obviously there might just be better design in the code before execution to handle this, but this is just an example.
flag? "It would be nice to just "get rid" of the if statement." Um, why?while(true) { // Do stuff ... if(buttonClicked()) { // Do other stuff } }thingclass ITaskwith avirtual void doSomething() = 0;method, and create various subclasses that do various things, and finally create vector/list of these objects that thewhile(true)-loop iterates over, callingdoSomething()on each in turn -- when you no longer want to do a task, you remove it from the vector/list and now the checks no longer occur for that task.