title: C++/CLI value class constraint won't compile. Why?
body: <p>a few weeks ago a co-worker of mine spent about two hours finding out why this piece of C++/CLI code won't compile with Visual Studio 2008 (I just tested it with Visual Studio 2010... same story).</p>
  
  <pre><code>public ref class Test
  {
      generic&lt;class T&gt; where T : value class
          void MyMethod(Nullable&lt;T&gt; nullable)
      {
  
      }
  };
  </code></pre>
  
  <p>The compiler says: Error    </p>
  
  <blockquote>
    <p>1 error C3214: 'T' : invalid type
    argument for generic parameter 'T' of
    generic 'System::Nullable', does not
    meet constraint 'System::ValueType
    ^'    C:\Users\Simon\Desktop\Projektdokumentation\GridLayoutPanel\Generics\Generics.cpp   11  1   Generics</p>
  </blockquote>
  
  <p>Adding <code>ValueType</code> will make the code compile.</p>
  
  <pre><code>public ref class Test
  {
      generic&lt;class T&gt; where T : value class, ValueType
          void MyMethod(Nullable&lt;T&gt; nullable)
      {
  
      }
  };
  </code></pre>
  
  <p>My question is now. Why? What is the difference between <code>value class</code> and <code>ValueType</code>?</p>
  
  <p>P.S: See the Nullable definition for C++: <a href="http://msdn.microsoft.com/de-de/library/b3h38hb0.aspx" rel="noreferrer">http://msdn.microsoft.com/de-de/library/b3h38hb0.aspx</a></p>