title: Decltype on class member as template argument
body: <p>I'm trying to pass the type of a class member as a template argument. For this I'm using the following code:</p>
  
  <pre><code>class C
  {
  public:
      int a;
  };
  class B
  {
  public:
      template&lt;typename _T&gt; void Test() {}
      // Specialize for int for Test testing purposes.
      template&lt;&gt; void Test&lt;int&gt;() { printf("Success!\n"); }
  };
  
  //Later:
  B b;
  C c;
  b.Test&lt;decltype(c.a)&gt;();
  </code></pre>
  
  <p>This gives me the following error:</p>
  
  <blockquote>
    <p>error C2662: 'void B::Test(void)' : cannot convert 'this' pointer
    from 'C' to 'B &amp;' Reason: cannot convert from 'C' to 'B' Conversion
    requires a second user-defined-conversion operator or constructor</p>
  </blockquote>
  
  <p>However, it does work if I use the following code:</p>
  
  <pre><code>decltype(c.a) d;
  b.Test&lt;decltype(d)&gt;();
  </code></pre>
  
  <p>Why doesn't it work if I simply use the class member directly?
  I'm using Visual Studio 2012.</p>