title: Dynamic Function in Cpp
body: <p>I have been working on a cpp project and I would like to make my function dynamically. 
  I have a function which has a bout 9 options when I am running.</p>
  
  <p>Let capital letter be a condition as boolean type, and small letter be a function. And let's assume that my function has its conditions(A-I) outside the function as a global scope. And the conditions would not be changed during runtime. It would be just set one time before running this function, and would not be changed during this function.</p>
  
  <pre><code>void Myfunction(){
  if(A) a(); // I would not use else if or switch since I should check all conditions.
  if(B) b();
  ...
  if(I) i();
  return;
  }
  </code></pre>
  
  <p>And the function would be called in a infinite-looped manner</p>
  
  <pre><code>int main(void){
  //Conditions A - I is declared here
  while (1) Myfunction;
  return 0;
  }
  </code></pre>
  
  <p>I do know that using if statement is quite slow and also checking non-variable conditions is kind of nonsense. In order for me to save computing resources and save time while running this function, I would like to make my function dynamically. Meaning that if first checking its conditions (A-I) then the function decides which expression to use.</p>
  
  <p>For example, if we have conditions A, B, C as true and all others(D - I) as false. 
  I would like to make the function automatically become.</p>
  
  <pre><code>void Myfunction(){
  a();
  b();
  c();
  return;
  }
  </code></pre>
  
  <p>I have searched the internet, however wasn't able to find any. 
  I found some articles about templates in cpp however it was not the case I was looking for.</p>
  
  <p>Thank you for reading this article.
  Since I am quite a new to Stackoverflow, I might have made some mistakes in this post.
  If there are anything in this post that is against Stackoverflow's rules, please please let me know. I would be more than happy to modify my post.</p>
  
  <p>Thank you.</p>