title: Does calling the constructor of an empty class actually use any memory?
body: <p>Suppose I have a class like</p>
  
  <pre><code>class Empty{
      Empty(int a){ cout &lt;&lt; a; }
  }
  </code></pre>
  
  <p>And then I invoke it using</p>
  
  <pre><code>int main(){
      Empty(2);
      return 0;
  }
  </code></pre>
  
  <p>Will this cause any memory to be allocated on the stack for the creation of an "Empty" object? Obviously, the arguments need to be pushed onto the stack, but I don't want to incur any extra overhead. Basically I am using the constructor as a static member.</p>
  
  <p>The reason I want to do this is because of templates. The actual code looks like</p>
  
  <pre><code>template &lt;int which&gt;
  class FuncName{
      template &lt;class T&gt;
      FuncName(const T &amp;value){
          if(which == 1){
              // specific behavior
          }else if(which == 2){
              // other specific behavior
          }
      }
  };
  </code></pre>
  
  <p>which allows me to write something like</p>
  
  <pre><code>int main(){
      int a = 1;
      FuncName&lt;1&gt;(a);
  }
  </code></pre>
  
  <p>so that I get to specialize one template parameter, while not having to specify the type of <code>T</code>. Also, I am hoping the compiler will optimize the other branches away inside the constructor. If anyone knows if this is true or how to check, that would be greatly appreciated. I assumed also that throwing templates into the situation does not change the "empty class" problem from above, is that right?</p>