title: Templates; constexpr ; compile time
body: <p>I have several questions</p>
  
  <p>1)</p>
  
  <pre><code>#include &lt;iostream&gt;
  template&lt;typename T&gt;
  void func(T t){}
  
  
  int main()
  {
   int i;
   double d;
   std::cin&gt;&gt;i;
  
  if(i==1)
   func(i);
  else
   func(d);
  }
  </code></pre>
  
  <p>When (runtime/compile time) does one generate needed function? How many versions of functions are after instantiation?</p>
  
  <p>2)What`s the difference between </p>
  
  <pre><code>template&lt;typename T&gt; auto func(T t){return 0;}
  </code></pre>
  
  <p>and</p>
  
  <pre><code>template&lt;typename T&gt; constexpr auto func(T t){return 0;}
  </code></pre>
  
  <p>As i understand <code>template</code> works at compile time and <code>constexpr</code> too. Why(and when) do i need to use  <code>constexpr</code> with templates?</p>