title: C++ expand variadic template arguments into a statement
body: <p>I'm currently playing around with template metaprogramming. I'm trying to make a finite state machine by using tmp. I know that there are several implementations in the web but I want to implement one by myself as an exercise. </p>
  
  <p>I have a class called <code>Condition</code> which is the base class for the condition of a transition between two states. One implementation is the <code>AnyCondition</code> class:</p>
  
  <pre><code>template&lt;class Input, Input comp, Input ... comps &gt;
  class AnyCondition: public Condition&lt;Input&gt;
  {    
  public:
      AnyCondition() {}
  
      bool operator()(const Input&amp; input) const override
      {
          return input == comp || AnyCondition&lt;Input, comps...&gt;()(input);
      }
  
  };
  </code></pre>
  
  <p>The thing here is, that the compiler will expand this recursivly, which results in a lot of recursive calls at runtime due to the <code>input</code> parameter. It should be more efficent, if the expanded code would be a statement like:</p>
  
  <pre><code>    bool operator()(const Input&amp; input) const override
      {
          return input == comp1 || input == comp2 || input == comp3...
      }
  </code></pre>
  
  <p>Is this possible somehow?</p>