title: error C2244 on templated member variable with templated argument function, only happens on Visual Studio
body: <p>I ran into an interesting, yet extremely annoying, bug on Visual Studio, below is the simplest repro: (uncomment the #define will allow VS to build the code)</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  //#define BUILD_ON_VS
  
  class CC
  {
  public:
     template&lt;typename T&gt;
     struct Foo
     {
        template&lt;T foo&gt;
        void bar()
        {
           cout &lt;&lt; "VC likes this!\n";
        }
  #ifndef BUILD_ON_VS
        template&lt;T foo&gt;
        void bar1();
  #endif
     };
  
     Foo&lt;int&gt; m_foo;
  };
  
  #ifndef BUILD_ON_VS
  template&lt;typename T&gt;
  template&lt;T foo&gt;
  void CC::Foo&lt;T&gt;::bar1()
  {
     cout &lt;&lt; "VC doesn't like this...\n";
  }
  #endif
  
  int main()
  {
     CC cc;
     cc.m_foo.bar&lt;-1&gt;();
  #ifndef BUILD_ON_VS
     cc.m_foo.bar1&lt;2&gt;();
  #endif
     return 0;
  }
  </code></pre>
  
  <p>Basically, I cannot put the definition of the function bar outside of the class in Visual Studio. bar and bar1 are exactly the same otherwise.
  Test on VS 2010 and VS 2012, both failed with errors:</p>
  
  <pre><code>error C2244: 'CC::Foo&lt;T&gt;::bar1' : unable to match function definition to an existing declaration
  definition
  'void CC::Foo&lt;T&gt;::bar1(void)'
  existing declarations
  'void CC::Foo&lt;T&gt;::bar1(void
  </code></pre>
  
  <p>It, however, works on all online compilers, such as compileonline and ideone.</p>
  
  <p>I want to keep everything inside the cpp file, not in the .h to keep the code base clean.</p>
  
  <pre><code>Setting var1 to:
  {
     template&lt;typename TT, TT foo&gt;
     void bar1();
  }
  
  template&lt;typename T&gt;
  template&lt;typename TT, TT foo&gt;
  void CC::Foo&lt;T&gt;::bar1()
  {
  }
  </code></pre>
  
  <p>Also works, but it makes the code looks idiotic by redefining the same template parameter and much more prone to bugs. It also makes the interface messy.</p>