title: Using __LINE__ macro as a template parameter in visual studio
body: <p>I expected the following code to work, but I received a compile error:</p>
  
  <blockquote>
  <pre><code>error C2975: 'n' : invalid template argument for 'foo', expected compile-time constant expression
  </code></pre>
  </blockquote>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  template&lt;int N&gt;
  struct foo
  {
      foo() { cout &lt;&lt; N &lt;&lt; endl; }
  };
  
  int main()
  {
      foo&lt; __LINE__ &gt; f;
  }
  </code></pre>
  
  <p>Why does this happen?  I though <code>__LINE__</code> would paste in the line number before template instantiation occurred?</p>
  
  <p>If I wanted to do this should I just introduce a <code>static const int</code> to hold the line number or is there a standard solution?</p>