title: How do I restrict a template class to certain built-in types?
body: <p>This issue has been discussed a few times but all the solutions I have found either didn't work or were based on boost's static assert. My problem is simple. I have a class, and I only want to allow real types (double and float). I want a compile-time error if I try to instantiate the class with a type other than float or double. I am using Visual C++ 11. Here is what I have tried:</p>
  
  <pre><code>template &lt;typename RealType&gt;
  class A
  {
    // Warning C4346
    static_assert(std::is_same&lt;RealType, double&gt;::value || std::is_same&lt;RealType, float&gt;::value);
  }
  
  
  template &lt;typename RealType&gt;
  class A
  {
    // Error C2062: type 'unknown' unexpected
    static_assert(decltype(RealType) == double || decltype(RealType) == float);
  }
  </code></pre>
  
  <p>Any ideas? Thanks in advance!</p>